VBA to create multiple range names

Ummm1

New Member
Joined
May 1, 2014
Messages
12
Hi,

I am converting a list of about 100 static named ranges to dynamic named ranges.
Within my workbook of data sheets I have a spreadsheet with the range names in one column and the new dynamic ranges in another.
The ranges are in this format: "$A$A:INDEX($A$A,COUNTA($A$A)".
I would like to use VBA to go through the names list and convert each static range to its dynamic range.
In the workbook there are thousands of formulas that refer to the static named ranges.
Apparently I know just enough VBA to spend a bunch of time getting nowhere.
Can anyone help? Thank you!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Untested, but maybe something like this. Change the range E1:F3 to the range occupied by your 'lookup table' that has range names in one column and the new dynamic ranges in the next column to the right of the names.
VBA Code:
Sub ChangeRangeNamesRefersTo()
Dim Nm As Name
For Each Nm In ActiveWorkbook.Names
    On Error Resume Next
    Nm.RefersTo = Application.VLookup(Nm.Name, Range("E1:F3"), 2, 0)  'change range to suit
    On Error GoTo 0
Next Nm
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,256
Messages
6,123,914
Members
449,132
Latest member
Rosie14

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