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

Hi All

From what I know, Excel doesn't support multiple areas in named ranges
Does anyone know of any get arounds to this limitation from the fron
end or by using VBA.

Secondly, if however, programmatically, using VBA, I do create a name
range say "myRange" referring to say :-

Sheet1!A1:C50,Sheet2!A1:C50

with comma delimited multiple areas as shown above (at least 2 areas
and which happen to be on different worksheets of the same workbook
and then write a custom function to evaluate the contents of each o
the cells within this named range, is it possible to determine th
worksheet names of each of the areas of the multiple area named rang
using the following statement :-

firstAreaWorksheetName = myRange.Areas(1).Parent.Name
secondAreaWorksheetName = myRange.Areas(2).Parent.Name etc.

Or am I on the wrong track?

Any suggestions would be highly valued.


Best regards



Deepak Agarwa

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Multiple areas in named ranges

You're on the wrong track. A range is a child object of a worksheet, so
a range cannot have areas in two different sheets. You could use a
collection, instead:

Dim colRanges As New Collection
Dim firstAreaWorksheetName As String
Dim secondAreaWorksheetName As String

colRanges.Add Sheets("Sheet1").Range("A1:C50").Cells
colRanges.Add Sheets("Sheet2").Range("A1:C50").Cells

firstAreaWorksheetName = colRanges(1).Parent.Name
secondAreaWorksheetName = colRanges(2).Parent.Name

MsgBox firstAreaWorksheetName & vbNewLine & secondAreaWorksheetName


In article ,
agarwaldvk wrote:

From what I know, Excel doesn't support multiple areas in named ranges.
Does anyone know of any get arounds to this limitation from the front
end or by using VBA.

Secondly, if however, programmatically, using VBA, I do create a named
range say "myRange" referring to say :-

Sheet1!A1:C50,Sheet2!A1:C50

with comma delimited multiple areas as shown above (at least 2 areas -
and which happen to be on different worksheets of the same workbook)
and then write a custom function to evaluate the contents of each of
the cells within this named range, is it possible to determine the
worksheet names of each of the areas of the multiple area named range
using the following statement :-

firstAreaWorksheetName = myRange.Areas(1).Parent.Name
secondAreaWorksheetName = myRange.Areas(2).Parent.Name etc.

Or am I on the wrong track?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Multiple areas in named ranges

Forgot to say that named ranges certainly can contain multiple areas
within one sheet:

Range("A1:J10,K11:T20").Name = "MyNamedRange"
MsgBox Range("MyNamedRange").Address


In article ,
agarwaldvk wrote:

From what I know, Excel doesn't support multiple areas in named ranges.
Does anyone know of any get arounds to this limitation from the front
end or by using VBA

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiple areas in named ranges

JE

Thanks for clarifying matters for me! Greatly appreciated.


Best regards


Deepak Agarwa

--
Message posted from http://www.ExcelForum.com

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
Multiple Named Ranges in the Same Column David Excel Worksheet Functions 2 May 9th 07 12:48 AM
Countif & ranges consisting of multiple areas Jurry Excel Worksheet Functions 2 November 15th 04 03:24 PM
Countif & ranges consisting of multiple areas Jurry Excel Worksheet Functions 0 November 15th 04 12:39 PM
Countif & ranges consisting of multiple areas Jurry Excel Worksheet Functions 1 November 15th 04 12:25 PM
Countif & ranges consisting of multiple areas Jurry Excel Worksheet Functions 1 November 15th 04 09:03 AM


All times are GMT +1. The time now is 06:15 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"