EssoExplJoe
New Member
- Joined
- Nov 11, 2016
- Messages
- 28
I am using the below code to find the last row that contains data on a worksheet. I have 50 rows that contain data on worksheet (ws) and when I run my macro using the below function to find the last used row, it returns 50 as it should. However, if I manually delete the data from the last 25 rows on the worksheet, the code still returns 50. How I get it to reset and return 25.. Note that there is a range variable set in the macro to include the number of used rows which is supposed to be reset each time the macro is run to the number of current used rows.
VBA Code:
Function FindLastRow(ws as worksheet) as long
FindLastRow= ws.UsedRange.Rows(sht.UsedRange.Rows.Count).Row
End Sub