Union method works only if name ranges are in a single sheet.some of my named ranges with "prices" in their name are no longer used and I wanted to move them to a new worksheet that I can hide
because you never know? just in case? it was a lot of work originally and it seems a waste to delete?If they are no longer used why not just delete them?
Sub Test2()
Dim nm
Dim c As Range
For Each nm In ActiveWorkbook.Names
If nm.Name Like "*prices" Then
If Range(nm.Name).Parent.Name = "Sheet1" Then
' Debug.Print nm.Name
If c Is Nothing Then
Set c = Range(nm.Name)
Else
Set c = Union(c, Range(nm.Name))
End If
End If
End If
Next nm
'now, c is holding all those named ranges.
If Not c Is Nothing Then
c.Select
Else
MsgBox "Can't find names that end with 'prices'"
End If
End Sub