OaklandJim
Well-known Member
- Joined
- Nov 29, 2018
- Messages
- 833
- Office Version
- 365
- Platform
- Windows
I know that this has probably been answered a million times but I cannot hack out the necessary code to find the last occupied row in a columnar range of data. Here are my hacky attempts so far.
VBA Code:
Function LastOccupiedRow(rData As Range) As Long
Debug.Print rData.Address '<= reports range G10:G109
' FYI the last occupied row in rData = 38
' This reports 1
LastOccupiedRow = Cells(rData.Rows.Count, 1).End(xlUp).Row
' These report 9
'LastOccupiedRow = rData.Cells(1).Resize(rData.Rows.Count).End(xlUp).Row
'LastOccupiedRow = rData.Cells(1, 1).Resize(rData.Rows.Count, 1).End(xlUp).Row
'LastOccupiedRow = rData.End(xlUp).Row
End Function