Macro Help

P

Paul Martin

I have recorded a macro in excel and would now like to modify it but i could
use some help.

The first element of the macro is: -

Range("A1:A2651").Select

This selects the records in column A from row 1 to row 2651. I would like to
modify this to select from column A a range that starts with the first row
with a numerical value in it down to the last. I need to do this as the
worksheet the rest of the macro is acting on has a varying number of rows in
it each time it is produced

Grateful for the help

Paul Martin
 
D

Dave Peterson

Dim LastRow as long
with activesheet
lastRow = .cells(.rows.count,"A").end(xlup).row
.range("a1:a" & lastrow).select
'or
.range("a1",.cells(.rows.count,"A").end(xlup)).select
end with

Sometimes using a variable makes it easier if you have to use it later on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top