Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro fails because of variable number of rows

Status
Not open for further replies.

louismx

Technical User
May 29, 2004
5
0
0
IE
Hello

I am using Ctl F to find end ( marked by = ) of a block of rows in a spread sheet. I then use CTL A to select from the end to beginning.

I want to use this command as a macro.
The blocks have a variable number of rows ranging 6 to 20 rows.
However when I run as macro it fails when the number of rows in the block changes.

Any ideas to solve would be appreciated.

Louis
 
This sounds very much like a VBA rather than a Vb question.

Good luck.

"Life is full of learning, and then there is wisdom"
 
You need to post your macro code - but I think you will find Macro Recorder cannot handle CtrlA sensibly and has changed it to e.g.
Range("A1:B9").Select

where you need something more like
Range(Selection, Cells(1)).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
This first goes back to top cell (it may not be Cells(1) in your block but you could remmeber cell you started from)
Second bit then selects all to Excel's special "Last cell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top