Last Active Row

  • Thread starter Thread starter Bill Sturdevant
  • Start date Start date
B

Bill Sturdevant

I want to loop through each row, doing verious things, and
I need to stop at the last active row. I never know
exactly how many rows are active.

What VB reference do I use to get that number:

For i = 1 to ??????
Do Stuff
next i
 
If you have data in the first row

For I = 1 To ActiveSheet.UsedRange.Rows.Count

Or if you only test data in one column

For I = 1 To ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
 
Bill try something like this.

Dim rng as Long
Set rng = Worksheets("sheet1").Cells(1,1).CurrentRegion

for i = 1 to rng.rows.count
'''' Do something '''
next i

HTH


Charle
 
the following works. don't know if it's elegant or not

Set dataSheet = ActiveShee
totalrows = dataSheet.UsedRange.Rows.Count
 
Back
Top