I have an inquiry on how to find the last row in excel vba. I am currently working on a project which requires me to find the last row of this particular worksheet called Annex 1A
.
A snip image of the worksheet is shown below:
For instance, from the image above, Row 32
and Row 33
contain empty values and I would like to derive the total of rows that is being used.
I have tried this following method :
Method 1
LastRow = Sheets("Annex 1A").Cells.Find(What:="*", _
After:=Sheets("Annex 1A").Range("B1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
Method 2
LastRow = Sheets("Annex 1A").Range("B" & Sheets("Annex1A").Rows.Count).End(xlUp).Row
The LastRow
value would always return 31
instead of 33
. Is there any other way for me to derive the value of 33
?