Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ranged name without "worksheet"

I am not too smart I guess, for I can't seem to find out how to refer
to (read) a named range when the specific work sheet is not known. (I
want to do this in VBS.)

I figured this out all on my own:

set rng = Workbook.Worksheets(1).Range("Name")

But what about when you know "Name" but not what sheet it is in?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default ranged name without "worksheet"

I am not too sure why you would not know what sheet your named range was in
but assuming you did not know you would need to loop through all of the
sheets to find it something like this

dim wks as worksheet
dim rng as range

on error resume next
for each wks in worksheets
set rng = wks.range("Name")
if not rng is nothing then exit for
next wks
--
HTH...

Jim Thomlinson


" wrote:

I am not too smart I guess, for I can't seem to find out how to refer
to (read) a named range when the specific work sheet is not known. (I
want to do this in VBS.)

I figured this out all on my own:

set rng = Workbook.Worksheets(1).Range("Name")

But what about when you know "Name" but not what sheet it is in?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default ranged name without "worksheet"

If you if it is a workbook level name

set rng = Workbooks("Book1.xls").Names("Name").RefersToRange

is pretty robust.

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
I am not too smart I guess, for I can't seem to find out how to refer
to (read) a named range when the specific work sheet is not known. (I
want to do this in VBS.)

I figured this out all on my own:

set rng = Workbook.Worksheets(1).Range("Name")

But what about when you know "Name" but not what sheet it is in?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ranged name without "worksheet"

set rng = Workbooks("Book1.xls").Names("Name").RefersToRange

ah! 'RefersToRange'! thanks

(if only Microsoft had an online reference that had more than a few
examples i actually may have found a reference to RefersToRange in
their reference on Ranges!)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ranged name without "worksheet"

I am not too sure why you would not know what sheet
your named range was in ...


this is my reasoning:

I have a fairly large spreadsheet, with much customer data in it
(there's one "workbook" per customer actually). And recently I have
been using VBSCRIPT to automate the office -- reports etc.

To make a long story short, if I move a named range from one worksheet
to another, I do not want to have to manually search for and replace
all references to the Worksheet name in all of the VBSCRIPT code.

thanks for your reply

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
"_Fill" and "_Key1" is contained in the worksheet I want to copy.. CWP Excel Discussion (Misc queries) 1 April 6th 10 06:08 PM
Turn off "CALCULATE" on bottom of Excel worksheet. near "Ready" chrispal86 Excel Discussion (Misc queries) 2 February 2nd 10 08:36 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
CommandBars("Worksheet Menu Bar").Controls("Tools").Enabled = Fals Arturo Excel Programming 3 May 26th 05 05:44 PM
Excel VBA - go to worksheet "name" based on a cell reference ="Name" james007 Excel Programming 2 July 8th 04 11:04 PM


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