Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Define Names / RefersToRange

hi,

i defined a Name "MyName" like

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

in VBA i wrote

Dim rng As Range
Set rng = ActiveWorkbook.Names("MyName").RefersToRange

but the code fails and the RefersToRange is nothing.

any idea?



--
André Achtermeier
----------------------------------------------
www.appliedtechnologies.de
----------------------------------------------


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Define Names / RefersToRange

What do you mean by "the code fails" - do you get a run-time error?
Does the line execute, but no assignment take place?

Is your name defined as a worksheet-level name?




In article ,
"Andre Achtermeier" wrote:

hi,

i defined a Name "MyName" like

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

in VBA i wrote

Dim rng As Range
Set rng = ActiveWorkbook.Names("MyName").RefersToRange

but the code fails and the RefersToRange is nothing.

any idea?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Define Names / RefersToRange

I can't reproduce it:

? range("myname").Address(externaL:=True)
[Book1]locACTIVE_Template!$P$49,$P$86
? activeworkbook.Names("MyName").RefersTo
=locACTIVE_Template!$P$49,locACTIVE_Template!$P$86
? activeworkbook.Names("MyName").ReferstoRange.addre ss(external:=True)
[Book1]locACTIVE_Template!$P$49,$P$86

set rng = activeWorkbook.Names("MyName").RefersToRange
? rng.Address(external:=True)
[Book1]locACTIVE_Template!$P$49,$P$86

Go into Insert=Names and make sure your definition is still good.

--
Regards,
Tom Ogilvy

"Andre Achtermeier" wrote in message
...
hi,

i defined a Name "MyName" like

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

in VBA i wrote

Dim rng As Range
Set rng = ActiveWorkbook.Names("MyName").RefersToRange

but the code fails and the RefersToRange is nothing.

any idea?



--
André Achtermeier
----------------------------------------------
www.appliedtechnologies.de
----------------------------------------------




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Define Names / RefersToRange

Note that I used a comma rather than a semicolon, but since you are in
Germany, a semicolon is probably appropriate.

--
Regards,
Tom Ogilvy

"Andre Achtermeier" wrote in message
...
hi,

i defined a Name "MyName" like

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

in VBA i wrote

Dim rng As Range
Set rng = ActiveWorkbook.Names("MyName").RefersToRange

but the code fails and the RefersToRange is nothing.

any idea?



--
André Achtermeier
----------------------------------------------
www.appliedtechnologies.de
----------------------------------------------




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Define Names / RefersToRange

hi,

thanx for the fast response.

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

is the Range which Excel adds after selecting the cells with
"Insert-Names..."

when i select only 1 cell everything works fine,
but the cells represent 2 different ranges (P49 AND P86)
the code fails, because the Range Object from RefersToRange is NOTHING....




"Tom Ogilvy" wrote in message
...
Note that I used a comma rather than a semicolon, but since you are in
Germany, a semicolon is probably appropriate.

--
Regards,
Tom Ogilvy

"Andre Achtermeier" wrote in message
...
hi,

i defined a Name "MyName" like

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

in VBA i wrote

Dim rng As Range
Set rng = ActiveWorkbook.Names("MyName").RefersToRange

but the code fails and the RefersToRange is nothing.

any idea?



--
André Achtermeier
----------------------------------------------
www.appliedtechnologies.de
----------------------------------------------








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Define Names / RefersToRange

Look at my previous response. I can't duplicate that behavior. It works
fine for me.

Try this. With locActive_Template as the active sheet, run this code

set rng = Union(range("P49"),range("P86"))
rng.name = "MyName"

msgbox thisworkbook.Names("MyName").RefersTo

Again, that code works for me.

--
Regards,
Tom Ogilvy

"Andre Achtermeier" wrote in message
...
hi,

thanx for the fast response.

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

is the Range which Excel adds after selecting the cells with
"Insert-Names..."

when i select only 1 cell everything works fine,
but the cells represent 2 different ranges (P49 AND P86)
the code fails, because the Range Object from RefersToRange is NOTHING....




"Tom Ogilvy" wrote in message
...
Note that I used a comma rather than a semicolon, but since you are in
Germany, a semicolon is probably appropriate.

--
Regards,
Tom Ogilvy

"Andre Achtermeier" wrote in

message
...
hi,

i defined a Name "MyName" like

=locACTIVE_Template!$P$49;locACTIVE_Template!$P$86

in VBA i wrote

Dim rng As Range
Set rng = ActiveWorkbook.Names("MyName").RefersToRange

but the code fails and the RefersToRange is nothing.

any idea?



--
André Achtermeier
----------------------------------------------
www.appliedtechnologies.de
----------------------------------------------








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
Questions on Define Names AccessHelp Excel Discussion (Misc queries) 3 November 10th 08 03:43 PM
Invalid define names Noreaster Charts and Charting in Excel 6 October 30th 08 01:48 AM
Define Names in Excel Dave T at home Excel Discussion (Misc queries) 2 November 1st 05 03:27 PM
how to define range names anton New Users to Excel 1 October 14th 05 08:28 AM
alternate UI for Define Names ?? jmg092548 Excel Discussion (Misc queries) 2 August 11th 05 01:32 PM


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