![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: Nanaimo, BC
Posts: 49
|
i need to be able to select a range using a macro. however, the range is going to vary according to some other cells. ie say the value in cell A1 is 5 and B1 is 10 and i want to select from I5 to I10 referencing A1 and B1, how do i do it?
thanx |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,384
|
Try something like this. The error trap is in case a non-valid value (a number less than 1 or greater than 65536, or a letter or symbol, etc) is in A1 or B1.
Sub SelectRange() On Error GoTo e Range("I" & [A1] & ":" & "I" & [B1]).Select Exit Sub e: MsgBox "Place a valid numeral in A1 or B1.", 48, "Can't determine range" End Sub |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: Nanaimo, BC
Posts: 49
|
works like a charm! thanks
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|