willie108
asked on
macro to select range
Hi. I tried recording a macro with relative references turned on.
I want to select a range that could have a varying number of rows except for the last row. I got the code attached but it has the references B46 which would not work if there were a different number of row. Anyone know what change to make?
Thank you.
I want to select a range that could have a varying number of rows except for the last row. I got the code attached but it has the references B46 which would not work if there were a different number of row. Anyone know what change to make?
Thank you.
Sub Macro2()
'
' Macro2 Macro
'
'
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:B46").Select
End Sub
ASKER
Thanks. I need to not select the last row. I want to select the whole range except the last row of the range.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Open in new window
Note, in Excel VBA you rarely, if ever, need to select something.