Hi Guys,
i have bunch of variables with different scopes.
But my name manager doesnt allow me to change it:
scope.PNG
why is that?
Where can i set up scopes for all variables?
Best,
Jacek
Hi Guys,
i have bunch of variables with different scopes.
But my name manager doesnt allow me to change it:
scope.PNG
why is that?
Where can i set up scopes for all variables?
Best,
Jacek
You have to delete the old name and recreate it with the required new scope.
Don
Please remember to mark your thread 'Solved' when appropriate.
Aa ok thank you!
So it is no possible to change a scope for already created variables...
Jacek
No, not directly. If I remember correctly, the Name Manager tool from Jan Karel Pieterse/Charles Williams does allow that, though I suspect it simply does the delete and recreate for you.
ok thank you !
Jacek
I did some searching on this subject a couple of years ago because I needed to change some names on a file at work where no add-ins are possible. I found some code which worked for me - but please check it on a copy of your file before using it on your actual file. It should change all names which are only worksheet-scope to workbook-scope.
Hope that helps.Please Login or Register to view this content.
Edit: note that there's no error checking in this macro. If there are two worksheet-scope Names with the same name, I don't know what the result will be.
Last edited by Aardigspook; 02-06-2018 at 02:42 PM. Reason: Add note about error checking
Regards,
Aardigspook
I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
You don't need to give me rep if I helped, but a thank-you is nice.
Thank you Aardigpook ,
your macro can be useful for others!
Jacek
Just to point out this is intentional by MS.
Named ranges have to have unique names, within their scope. This means you can have a named range called "MyRange" with a scope of Workbook and another named range with the same name with a scope of Sheet1, but you cannot have 2x workbook scope with the same name or 2x Sheet1 with the same name.
Ok, easy enough Excel should just check if the name you try and rename it to already exists. Sure they could but...
The scope of a named range would likely impact the refers to as well, at least in terms of what you would want it to refer to. Excel cant really check if it refers to what you want it to.
Lastly, copy/paste. Its possible to duplicate named ranges without even knowing you have using copy/paste. I believe the scope changes when this happens (at least for workbook scope named ranges, they get copied as sheet level) to prevent them from completely breaking.
With all the above allowing people to rename could be a mess. As pointed out, either recreating them or using a macro/3rd party solution should work.
Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.
"I am here to help, not do it for people" -Me
Yes, it may be intentional but it is stupid. Somehow, a bunch of my named ranges got converted from Workbook scope to Worksheet scope, probably because I created a copy of the sheet defining them. And now it won't let me redo the scope. I want to delete one and change the other to workbook scope. Seems like a completely reasonable thing to do. But instead, I have to delete both of them and recreate one of them as Workbook scope. Typical stupid microsoft BS! Software that is "just good enough".
Well that worked swimmingly! Thank you!
Hi Aardigspook,
Thank you so much for your code. It worked like a dream.
All the best
Ekki
Aardigspook
You are a life saver!
I Sincerely Thank you
greed98
Hi, I am new to the forum. Thank you for the macro! I installed the macro in my Excel Personal file and ran it. I did not get an error message but the scopes of my formula names were unchanged. What am I missing? Is there a requirement that the macro run from the workbook that has the issue? Any help you can offer is appreciated. Thank you
Last edited by ericgpe; 12-01-2023 at 04:22 PM.
Hi ericgpe,
Yes, you need to run the macro from the workbook which you want to change. To do this, open the Visual Basic editor (press Alt-F11), make sure you select the correct workbook on the left-hand side, insert a new module, copy/paste the code, then run it. After it's run, you can save the workbook as a normal .xlsx file and the macro will be deleted (you'll get a warning dialogue box about this) or save it as a macro-enabled .xlsm file and it'll be kept.
Hope that helps.
AS
Hi Aardigspook,
How are you? This code works for me, thanks.
This was possible (and easy) in Excel versions up to 2003. Yet another useful feature that Microsoft decided to remove.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks