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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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