Home > Software design >  Excel VBA - End(xlUp).Row not working as expected
Excel VBA - End(xlUp).Row not working as expected

Time:06-06

I need to count the rows with data, starting from a certain row to the last one.

Let's pretend in column "A" I have these 3 rows:
150
185
350

With this code:

LastRow = sht.Range(SpecificColumn & StartingRow).End(xlUp).Row  

With this values: SpecificColumn = "A"
StartingRow = 1 or 2 or 3

I always get LastRow = 1

What am I doing wrong?

CodePudding user response:

Direction will be down, not up. Try-

LastRow = sht.Range(SpecificColumn & StartingRow).End(xlDown).Row  

Or

LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row  
  • Related