Skip to content

Instantly share code, notes, and snippets.

View MartinP7r's full-sized avatar
📱

Martin Pfundmair MartinP7r

📱
View GitHub Profile
@MartinP7r
MartinP7r / endOfSheet.bas
Last active August 29, 2015 14:01
returns the (actual) last row of the current Excel Sheet
Function endOfSheet(Optional targetSheet As Worksheet) As Long
'' returns the (actual) last row of the current sheet
' this is far better than using '65536' or whatever the current row size might be,
' especially since .xlsx has 2^20 (1048576), not 2^16.
If targetSheet Is Nothing Then
Set targetSheet = ActiveWorkbook.ActiveSheet
End If
endOfSheet = targetSheet.Rows.Count
End Function