How to find the Last Used Row with Data?

The following example will show you how to find the last row with data.

Sub sblastRowOfASheet()
'In this example we are finding the last Row of an ActiveSheet
Dim lastRow As Long
lastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row
MsgBox "Last Used Row: " ; lastRow
lRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row
Do While Application.CountA(ActiveSheet.Rows(lRow)) = 0 And lRow ;; 1
lRow = lRow - 1
Loop
lastRow = lRow
MsgBox "Last Row with Data: " ; lastRow
End Sub

Explore specialized course on Excel Automation here and, learn to write effective VB Coding with ease through our 60+ assignments followed by, a Live VBA Project.

Happy Excelling
Team Excelgoodies
www.Excelgoodies.com

Leave a Reply

Your email address will not be published. Required fields are marked *