Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default retrieving named ranges from another sheet

I currently do this inside a subroutine

Set Holidays_r = Names("Holidays").RefersToRange

to access a certain range on a sheet.

I was wondering how would I access the same named range that exists on
a seperate sheet that may or may not be opened? Do I have to open
that workbook first?


Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default retrieving named ranges from another sheet

So I assume that this named range is in a seperate workbook. If that is the
case then yes you need to open the other workbook. At that point it is fairly
easy, just make sure that you are explicit in your referencing as it becomes
more important when you are dealing with multiple open workbooks.
--
HTH...

Jim Thomlinson


" wrote:

I currently do this inside a subroutine

Set Holidays_r = Names("Holidays").RefersToRange

to access a certain range on a sheet.

I was wondering how would I access the same named range that exists on
a seperate sheet that may or may not be opened? Do I have to open
that workbook first?


Thanks


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default retrieving named ranges from another sheet

To your 2 part question:

Question 1: Does the workbook with the range name need to be open?

Answer: Yes. It's the same thing that I have stated about calculations.
Calculations from a closed workbook should take place, but it doesn't seem
to work, but then I also have more complex formulas in some of my workbooks,
thus why the "F9" key doesn't work for full calculation in manual
calculation mode, which is why I strictly use the "Ctrl-Alt-F9" key
combination for full calculations.

Same type deal, for VBA to see the objects, they must be opened to be able
to read the objects and their related attributes.

Question 2: How do I have it refer to a different workbook that the range
name is in?

Answer: The way you have the "Names" collection object reference, it's
refering to the active workbook. If you don't like the symptoms that it
gives or need to specify which workbook object to refer to as the Names
collection is part of a workbook object, then use the following example:

'Assuming "Book1.xls" is already open, and the range name of "Holidays"
exist in "Book1.xls"

Dim wbkBook1 As Excel.Workbook, rngHolidays As Excel.Range
Set wbkBook1 = Workbooks("Book1.xls")
Set rngHolidays = wbkBook1.Names("Holidays").RefersToRange


--

Sincerely,

Ronald R. Dodge, Jr.
Master MOUS 2000

wrote in message
ups.com...
I currently do this inside a subroutine

Set Holidays_r = Names("Holidays").RefersToRange

to access a certain range on a sheet.

I was wondering how would I access the same named range that exists on
a seperate sheet that may or may not be opened? Do I have to open
that workbook first?


Thanks



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
Names of named ranges in active sheet only Tom Ogilvy Excel Programming 0 December 8th 06 03:45 AM
Names of named ranges in active sheet only Norman Jones Excel Programming 0 December 7th 06 01:45 PM
Delete broken named ranges in sheet akyhne[_2_] Excel Programming 13 August 15th 05 10:53 PM
Copying named ranges from one sheet to another Mark Stephens Excel Programming 3 August 4th 05 02:54 PM
How do I delete all named ranges in a sheet at one time? L.Wall Excel Worksheet Functions 2 July 13th 05 03:29 PM


All times are GMT +1. The time now is 10:12 AM.

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

About Us

"It's about Microsoft Excel"