Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Named Range Collection

Is there a named range collection in Excel? Or would I have to create this
collection by looping through all the cells in the UsedRanage and testing to
see if each range had a name?

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Named Range Collection

The Workbook.Names collection contains all the workbook-wide names. The
Worksheet.Names collection contains the sheet level names. E.g.,


Dim WS As Worksheet
Dim N As Name
For Each N In ThisWorkbook.Names
Debug.Print N.Name, N.RefersTo
Next N
For Each WS In ThisWorkbook.Worksheets
For Each N In WS.Names
Debug.Print N.Name, N.RefersTo
Next N
Next WS


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





"ExcelMonkey" wrote in message
...
Is there a named range collection in Excel? Or would I have to create
this
collection by looping through all the cells in the UsedRanage and testing
to
see if each range had a name?

Thanks

EM


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Named Range Collection

Excellent.

Thanks

EM

"Chip Pearson" wrote:

The Workbook.Names collection contains all the workbook-wide names. The
Worksheet.Names collection contains the sheet level names. E.g.,


Dim WS As Worksheet
Dim N As Name
For Each N In ThisWorkbook.Names
Debug.Print N.Name, N.RefersTo
Next N
For Each WS In ThisWorkbook.Worksheets
For Each N In WS.Names
Debug.Print N.Name, N.RefersTo
Next N
Next WS


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





"ExcelMonkey" wrote in message
...
Is there a named range collection in Excel? Or would I have to create
this
collection by looping through all the cells in the UsedRanage and testing
to
see if each range had a name?

Thanks

EM


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Named Range Collection

So, If I had a WS with many named ranges and I wanted to copy them to a
different WS in a different WB, can I copy the whole collection in one
assignement:

ThisWorkbook.Worksheet("Lists).Names =
workbooks("OtherWB").Worksheets("Lists").Names

Or do I need to loop through the list?

Thanks,
John

"Chip Pearson" wrote:

The Workbook.Names collection contains all the workbook-wide names. The
Worksheet.Names collection contains the sheet level names. E.g.,


Dim WS As Worksheet
Dim N As Name
For Each N In ThisWorkbook.Names
Debug.Print N.Name, N.RefersTo
Next N
For Each WS In ThisWorkbook.Worksheets
For Each N In WS.Names
Debug.Print N.Name, N.RefersTo
Next N
Next WS


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





"ExcelMonkey" wrote in message
...
Is there a named range collection in Excel? Or would I have to create
this
collection by looping through all the cells in the UsedRanage and testing
to
see if each range had a name?

Thanks

EM


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Named Range Collection


ThisWorkbook.Worksheet("Lists).Names =
workbooks("OtherWB").Worksheets("Lists").Names


That won't work at all. It won't even compile.

To copy the Names from Book1 to Book2, such that the new names in
Book2 refer to the same cell addresses, use

Dim WB1 As Workbook
Dim WB2 As Workbook
Dim NM As Name

Set WB1 = Workbooks("Book1")
Set WB2 = Workbooks("Book2")

For Each NM In WB1.Names
WB2.Names.Add Name:=NM.Name, RefersTo:=NM.RefersTo
Next NM


If you want to copy the data along with the names, use

Dim WB1 As Workbook
Dim WB2 As Workbook
Dim NM As Name

Set WB1 = Workbooks("Book1")
Set WB2 = Workbooks("Book2")

For Each NM In WB1.Names
WB2.Names.Add Name:=NM.Name, RefersTo:=NM.RefersTo
WB2.Names(NM.Name).RefersToRange.Value = NM.RefersToRange.Value
Next NM


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




On Mon, 24 Aug 2009 08:11:01 -0700, DocBrown
wrote:

So, If I had a WS with many named ranges and I wanted to copy them to a
different WS in a different WB, can I copy the whole collection in one
assignement:

ThisWorkbook.Worksheet("Lists).Names =
workbooks("OtherWB").Worksheets("Lists").Names

Or do I need to loop through the list?

Thanks,
John

"Chip Pearson" wrote:

The Workbook.Names collection contains all the workbook-wide names. The
Worksheet.Names collection contains the sheet level names. E.g.,


Dim WS As Worksheet
Dim N As Name
For Each N In ThisWorkbook.Names
Debug.Print N.Name, N.RefersTo
Next N
For Each WS In ThisWorkbook.Worksheets
For Each N In WS.Names
Debug.Print N.Name, N.RefersTo
Next N
Next WS


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





"ExcelMonkey" wrote in message
...
Is there a named range collection in Excel? Or would I have to create
this
collection by looping through all the cells in the UsedRanage and testing
to
see if each range had a name?

Thanks

EM


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
Getting a collection of named ranges using wildcard characters? Randy Harmelink Excel Programming 2 November 7th 06 02:04 AM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
If any cell in named range = 8 then shade named range JJ[_8_] Excel Programming 3 August 26th 05 11:09 PM
Range collection Ernst Guckel[_4_] Excel Programming 4 May 1st 05 08:01 PM
Deleting named ranges by looping through range collection agarwaldvk[_11_] Excel Programming 3 August 3rd 04 01:00 AM


All times are GMT +1. The time now is 02:49 AM.

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"