![]() |
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 ---------------------------------------------- |
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? |
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 ---------------------------------------------- |
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 ---------------------------------------------- |
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 ---------------------------------------------- |
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 ---------------------------------------------- |
All times are GMT +1. The time now is 07:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com