Try the following:
Sub ListNames()
' Purpose: Paste a list of all range names on a new sheet
Sheets.Add
Selection.ListNames
Selection.Columns.AutoFit
ActiveCell.Select
ActiveSheet.Name = "ListRanges"
End Sub
Sub RecreateNamedRanges()
' Purpose: * Remove all range names
' * Recreate range names that appear in list
' Restrictions: Active cell must currently be sitting within
' a list of range names and the range to which they
' refer. The list should start at cell A1 on an
' otherwise blank sheet.
Dim nm As Name
Range("A1").Select
' a pasted list of range names will have the following:
' * sheet name = "ListRanges"
' * column 1 = no space in range name
' * column 2 = range starting with "="
' * column 3 = blank
If ActiveSheet.Name = "ListRanges" And _
InStr(1, ActiveCell.Formula, " ") = 0 And _
Left(ActiveCell.Offset(0, 1).Formula, 1) = "=" And _
ActiveCell.Offset(0, 2).Formula = "" Then
If vbYes = MsgBox("This macro will do the following:" & vbCrLf & vbCrLf & _
vbTab & "* delete all range names" & vbCrLf & _
vbTab & "* recreate only the range names in this list" & vbCrLf & _
vbTab & "* delete the 'ListRanges' sheet" & vbCrLf & vbCrLf & _
"Continue?", vbQuestion + vbYesNo + vbDefaultButton2, _
"Recreate Range Names?") Then
' delete all range names
For Each nm In ActiveWorkbook.Names
On Error Resume Next
nm.Delete
Next nm
' loop through list redefining listed range names
Do Until ActiveCell.Formula = ""
ActiveWorkbook.Names.Add ActiveCell.Formula, ActiveCell.Offset(0, 1).Formula
ActiveCell.Offset(1, 0).Select
Loop
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
MsgBox "The listed range names have been recreated.", vbInformation, _
"Range Names Completed"
End If
Else
MsgBox "Please run 'ListNames' macro prior to recreating range names.", vbInformation, _
"Range Names Missing"
End If
End Sub
The first macro creates a new sheet listing all range names. The second macro deletes all range names, then recreates only those appearing in the list.
The idea here is that after listing all range names, you delete any row containing names you want to remove. You can also fix up any errors, perform a search and replace on ranges, and manually add new ranges. When you run the second macro, all range names in your updated list are created.
I used something like this on some very large workbooks containing over 200 range names that often didn't behave as they were supposed to!!!