Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 -- jayy ------------------------------------------------------------------------ jayy's Profile: http://www.excelforum.com/member.php...o&userid=33975 View this thread: http://www.excelforum.com/showthread...hreadid=538563 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
RESIZE USEDRANGE | Excel Programming | |||
usedRange | Excel Programming | |||
usedrange | Excel Programming | |||
UsedRange | Excel Programming | |||
Usedrange | Excel Programming |