Loop QUESTION to end of data range...

  • Thread starter Thread starter mniccole
  • Start date Start date
M

mniccole

HI:
Can you tell me how to loop to the end of the data range without this
being static?
Please

numrows = Range("A2", Range("A2").End(xlDown)).Rows.Count
Range("A2").EntireColumn.Select

For x = 1 To 3000

Thanks so much

Just need to go to the end value which will change everytime the report
is ran by user
 
Try something like the following:

Dim FirstRow As Long
Dim LastRow As Long
Dim RowNdx As Long

FirstRow = 2
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = FirstRow To LastRow
' do something
Next RowNdx

By the way, the worksheet.functions newsgroup is not the best place for
VBA-related questions. It is for worksheet formula questions. The
programming newsgroup is the place for VBA questions.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Hi

numrows = Cells(Rows.Count, 1).End(xlUp).Row
will find the last used row number in column 1 (column A)

Range("A" & numrows).Select
will take you to that last cell used in column A.
If you want the first empty one after last used then

Range("A" & numrows + 1).Select
 

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

Similar Threads


Back
Top