Mass renaming of named ranges

Fishboy

Well-known Member
Joined
Feb 13, 2015
Messages
4,267
Hi all,

Another day another query it seems! I have an Excel 2010 workbook and am looking to mass rename a whole load of named ranges. Having spent the last 30 or so minutes doing so manually, I then scrolled through the list and realised I wasn't even a quarter of the way through yet.

Fortunately there is a common factor for all the ranges yet to be renamed and that is the fact they all start with L and none of the amended ones do, so what I am hoping is for some simple VBA that will check the current workbook for named ranges beginning with L and add Charts_ as a new prefix to the existing name.

Is anyone able to offer any suggestions please?

Many thanks!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Does this get you started?

Code:
Sub a()
For Each nm In ThisWorkbook.Names
If Left(nm.Name, 1) = "L" Then nm.Name = "Chart_" & Mid(nm.Name, 2)
Next
End Sub
 
Upvote 0
Hi Dave,

Thanks for your reply. I'll give this a quick test on a copy of my workbook and hopefully get back to you shortly with some positive feedback!
 
Upvote 0
Hi again Dave,

That was great. I did have to make a very minor adjustment (namely changing "Chart_" to "Chart_L") so that it added Chart_ as a prefix to the existing name without replacing the L at the start of the name, but without your initial code I would have been here for hours.

Many thanks mate. A great big LIKE to your post.
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,933
Members
449,195
Latest member
Stevenciu

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