I'm just starting to work with functions in VBA. Does something like this look ok to use when getting the first and last rows of the used range? I'm wondering if there's a better or more efficient way of doing this.
-----
Sub test()
a = rangeUsed(0)
b = rangeUsed(1)
MsgBox "first row = " & a & vbLf & "last row = " & b
End Sub
Function rangeUsed()
Dim firstRow As Long, lastRow As Long
With ActiveSheet.UsedRange.Rows
firstRow = .Row
lastRow = .Count + (firstRow - 1)
End With
rangeUsed = Array(firstRow, lastRow)
End Function
-----
Thanks.
Jay
Bookmarks