![]() |
![]() |
|
|||||||
| 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 |
|
Join Date: Apr 2002
Location: Chicago
Posts: 8
|
What is the syntax to put a range in a variable from an array of names?
I have an array where I am storing the names of certain ranges, now I want to use them, I can't figure out how to do it!! dim myRange as Range myRange = Range(myArray(i)) The above won't work?! myArray is a string array and i could be 1 here. What is the proper syntax. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, Colorado USA
Posts: 3,884
|
Hi Jimijon,
You must use the Set keyword because a range is an object, and myRange is therefore a Range object variable. So... dim myRange as Range Set myRange = Range(myArray(i))
__________________
Keep Excelling. Damon VBAexpert Excel Consulting (My other life: http://damonostrander.com ) |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|