-
Ok, so the last row discussion came up over on MrExcel... And I think this function from Rorya may account for more vagaries than the "usedrange" approach we were discussing.
[VBA]
Public Function LastRowInSheet(wks As Worksheet) As Long
'From Rorya on MrExcel:
'http://www.mrexcel.com/forum/showthread.php?p=1793851&posted=1#post17938521
' Returns the number of the last row with data anywhere in it
LastRowInSheet = 1
On Error Resume Next
With wks.UsedRange
LastRowInSheet = .Cells.Find("*", .Cells(1), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
End With
End Function
[/VBA]
Cordially,
Aaron
Keep Our Board Clean! - Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
- Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules