named ranges...need to refer to the worksheet??

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
391
hi when using named ranges in vba....i found that you dont necessarily need to refer to the worksheet


e.g let's say i have named range "desk" in the tab "A"

usually in VBA i can just do range("desk").copy

but for this one particular file, it doesn't work...i actually need to do this:

sheets("a").range("desk").copy



Why is that???
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,206
Office Version
365
Platform
Windows
Sounds like that name is scoped at sheet level, rather than workbook level
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,317
I suspect the scope of the named range "desk" is Worksheet, not Workbook (check on Names Manager) and that the active sheet when your code reaches this line is not sheet "a".

M.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,206
Office Version
365
Platform
Windows
Not sure you can.
You'll probably need to delete the range & then re-set it.
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,317
thank you, but how do you change it? it's greyed otut

I do not think you should change the scope (risky) - maybe there is some reason for that to be so.
Use
Sheets ("a").Range("desk").Copy
or
Sheets ("a"). Activate
Range ("desk"). Copy

M.
 
Last edited:

daveyc18

Active Member
Joined
Feb 11, 2013
Messages
391
Not sure you can.
You'll probably need to delete the range & then re-set it.
some googling ...a guy simply went to that named ranged...."defined" the name agai via Name Manager and then, of course, Excel told him the name was already in use....yet after he pressed OK it worked! unfortuantely, didnt work for me as he did it in excel 2007 (im using 2010)

oh well..
 

Forum statistics

Threads
1,081,976
Messages
5,362,514
Members
400,679
Latest member
alecalec202

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top