I have a spreadsheet with data in columns “A” through “E” and a varying amount of rows. I am looking for some help on how to be able to dynamically determine the last row with data. The purpose for finding the last row of data is to be able to do some sorting and subtotaling. I was able to use a macro and my limited knowledge to get the subtotaling and sorting to work. However I don’t know how to determine the last row of data. Listed below is some code I am attempting to make work. The code will check the rows for data but how do I assign the ‘row number’ to a variable for use later when sorting/subtotaling??
Dim R As Range Dim cell As Range Dim rowNum As Integer Set R = Range("D1:D2000") 'would never be more than 2000 rows For Each cell In R If IsEmpty(cell) Then rowNum = ???????????? End If Next
The code in red is what I am not sure about. Please help. TIA