UsedRange method to find the last used row number in a worksheet


Sub LastUsedRow_UsedRange_1()

Dim lastRow As Long

lastRow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count

MsgBox lastRow

End Sub



Sub LastUsedRow_UsedRange_2()

Dim lastRow As Long

lastRow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row

MsgBox lastRow
End Sub

Comments

Popular posts from this blog

50 Excel VBA Oral Interview Questions