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

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
707
Office Version
  1. 365
  2. 2010
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???
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Sounds like that name is scoped at sheet level, rather than workbook level
 
Upvote 0
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.
 
Upvote 0
Not sure you can.
You'll probably need to delete the range & then re-set it.
 
Upvote 0
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:
Upvote 0
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..
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top