How to determine the last Row used in VBA including blank spaces in between
excel, vba
Solution
You're really close. Try using a large row number with `End(xlUp)`
Function ultimaFilaBlanco(col As String) As Long
Dim lastRow As Long
With ActiveSheet
lastRow = ActiveSheet.Cells(1048576, col).End(xlUp).row
End With
ultimaFilaBlanco = lastRow
End Function
Problem
How can I determine the last row in an Excel sheet, including some blank lines in the middle? With this function: ``` Function ultimaFilaBlanco(col As String) As Long Dim lastRow As Long With ActiveSheet lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, col).End(xlUp).row End With ultimaFilaBlanco = lastRow End Function ``` And this data: ``` Row 1 : Value Row 2 : Value Row 3 : Value Row 4 : Value Row 5 : Value Row 6 : White Row 7 : Value Row 8 : Value Row 9 : Value Row 10 : White Row 11 : White Row 12 : White Row 13 : Value Row 14 : White ``` The function returns 5, and I need 13. Any idea how to do it?