I have two named ranges which share the same "label/name" at both the workbook level and the worksheet level. I need to refer to the one at the workbook level in VBA. How can I do that? Everytime I do it, it's referring to the first one listed which is the worksheet level one. Why and how? Actually what happened is I had one named range named "myRange" at the workbook level. But, when the user copied the sheet that name was applied to, Excel created another instance of that named range, but at the sheet level. I need the named range on my original sheet - the workbook level name in order for the rest of my code to work.
Let's say you create a named range for cell A1 on "Sheet 1" named "myRange". Then, you copy that sheet which creates "Sheet 1 (2)". What Excel does (unless you can tell me a way to prevent this) is copy the "myRange" named range so that you now have one at the worksheet level too. So in the "Name Manger" you'll now see two named ranges sharing the same name at two levels:
Name 1: myRange Scope: Sheet 1 (2)
Name 2: myRange Scope: Workbook
Then, if I do this:
Debug.print ActiveWorkbook.Names("myRange").Parent
It will return "Sheet1 (2)", but what I really want it to return is "Sheet 1"
Thoughts?
Your help is very appreciated!
Bookmarks