Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting multiple named ranges

I have a macro that looks at the active cell and determines the named
ranges that it is a part of. It can be one named range or many. I
store the names in an array, one name per element in the array.
After populating the array with the names, I want to select all of the
named ranges that have been stored in the array.
I can do this easily like this: Range(“mg_benefits, mg_FY11,
mg_fy12”).select, but when I try to do the same thing from my array it
doesn’t work.
My array is: Dim vSelections(1 to 100) as Variant
I fill the first three elements with the names above. I’ve tried
Range("vSelections(1), vSelections(2),vSelection(3)").Select
and
Range(vSelections(1), vSelections(2) ,vSelection(3)).Select
But these don’t work. I think I’m missing something simple, but I
can’t figure it out. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Selecting multiple named ranges

use the UNION method

Option Explicit
Sub demo()
Dim target As Range
Set target = Union(Range("A1:A5"), Range("C5:D10"), Range("B15:F15"))
target.Select
End Sub


"Ted M H" wrote in message
...
I have a macro that looks at the active cell and determines the named
ranges that it is a part of. It can be one named range or many. I
store the names in an array, one name per element in the array.
After populating the array with the names, I want to select all of the
named ranges that have been stored in the array.
I can do this easily like this: Range(“mg_benefits, mg_FY11,
mg_fy12”).select, but when I try to do the same thing from my array it
doesn’t work.
My array is: Dim vSelections(1 to 100) as Variant
I fill the first three elements with the names above. I’ve tried
Range("vSelections(1), vSelections(2),vSelection(3)").Select
and
Range(vSelections(1), vSelections(2) ,vSelection(3)).Select
But these don’t work. I think I’m missing something simple, but I
can’t figure it out. Any suggestions?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Index and named ranges selecting difficulty Bruce Tharp Excel Worksheet Functions 7 June 19th 07 02:49 AM
Selecting multiple ranges RWN Excel Programming 4 December 18th 06 12:34 AM
Selecting multiple ranges [email protected] Excel Programming 5 February 2nd 06 06:49 PM
Selecting Named Ranges Ian[_8_] Excel Programming 7 September 22nd 03 03:32 PM


All times are GMT +1. The time now is 01:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"