Sub Test1()
Dim nm
Dim c As Range
For Each nm In ThisWorkbook.Names
If nm.Name Like "*prices" 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
Next nm
'now, c is holding all those named ranges.
c.Select
End Sub
Sub Test2()
Dim nm
Dim c As Range
For Each nm In ActiveWorkbook.Names
If nm.Name Like "*prices" 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
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 'price'"
End If
End Sub
For Each nm In Workbooks("something").Names
Private Sub selectprices_Click()
Dim nm
Dim c As Range
For Each nm In ActiveWorkbook.Names
If nm.Name Like "*prices" 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
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