Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Ensure Named Range is in ThisWorkbook

I'm working on a project where I will have numerous workbooks open with
lots of named ranges. I'm trying to figure out how to ensure that when
I call a named range, ie:

dim myRange as Range
set myRange = Range("Named Range")

that I am getting the range in the workbook that the macro is written
in. Really, I want this:

dim myRange as Range
set myRange = Range(ThisWorkbook."Named Range")

but it obviously doesn't work like that (just I hope an easy way of
explaining what I'm looking for).

Thanks in advance,

John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Ensure Named Range is in ThisWorkbook

John,

John:

In the Thisworkbook module, tests for range in the active workbook:

Sub rangetest()
On Error Resume Next
If Range("Test").Name Is Nothing Then
MsgBox "Range does not exist"
Else:
MsgBox "Range does exist"
End If
End Sub

Alan

John Fuller wrote:
I'm working on a project where I will have numerous workbooks open with
lots of named ranges. I'm trying to figure out how to ensure that when
I call a named range, ie:

dim myRange as Range
set myRange = Range("Named Range")

that I am getting the range in the workbook that the macro is written
in. Really, I want this:

dim myRange as Range
set myRange = Range(ThisWorkbook."Named Range")

but it obviously doesn't work like that (just I hope an easy way of
explaining what I'm looking for).

Thanks in advance,

John


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Ensure Named Range is in ThisWorkbook

John, use thiskind ofscript :

Sub test()
Dim rMyRange As Range
Set rMyRange = ThisWorkbook.Names("myRange").RefersToRange
End Sub

where "ThisWorkbook"is the default "CodeName" for the workbook in the visual
basic project (but it can be modified to be clearer like wkbDataTransfered)

"John Fuller" wrote:

I'm working on a project where I will have numerous workbooks open with
lots of named ranges. I'm trying to figure out how to ensure that when
I call a named range, ie:

dim myRange as Range
set myRange = Range("Named Range")

that I am getting the range in the workbook that the macro is written
in. Really, I want this:

dim myRange as Range
set myRange = Range(ThisWorkbook."Named Range")

but it obviously doesn't work like that (just I hope an easy way of
explaining what I'm looking for).

Thanks in advance,

John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Ensure Named Range is in ThisWorkbook

John,
MsgBox Range("rngTest").Parent.Parent.Name=ThisWorkbook.N ame

NickHK

"John Fuller" wrote in message
ps.com...
I'm working on a project where I will have numerous workbooks open with
lots of named ranges. I'm trying to figure out how to ensure that when
I call a named range, ie:

dim myRange as Range
set myRange = Range("Named Range")

that I am getting the range in the workbook that the macro is written
in. Really, I want this:

dim myRange as Range
set myRange = Range(ThisWorkbook."Named Range")

but it obviously doesn't work like that (just I hope an easy way of
explaining what I'm looking for).

Thanks in advance,

John



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Ensure Named Range is in ThisWorkbook

Thanks all. I'll give them a try.


NickHK wrote:
John,
MsgBox Range("rngTest").Parent.Parent.Name=ThisWorkbook.N ame

NickHK

"John Fuller" wrote in message
ps.com...
I'm working on a project where I will have numerous workbooks open with
lots of named ranges. I'm trying to figure out how to ensure that when
I call a named range, ie:

dim myRange as Range
set myRange = Range("Named Range")

that I am getting the range in the workbook that the macro is written
in. Really, I want this:

dim myRange as Range
set myRange = Range(ThisWorkbook."Named Range")

but it obviously doesn't work like that (just I hope an easy way of
explaining what I'm looking for).

Thanks in advance,

John


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
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
Set Range on ThisWorkBook problem. Cesar Zapata Excel Programming 1 January 31st 06 10:35 PM
If any cell in named range = 8 then shade named range JJ[_8_] Excel Programming 3 August 26th 05 11:09 PM
Is it possible to ensure Calendar date is in range Robert Hargreaves Excel Programming 1 May 27th 05 08:38 PM


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