This for each loop will check out all the named range in my active sheet and do something.
Sub Test1
For Each namedRanges In ActiveWorkbook.Names
If namedRanges.RefersToRange.Parent.Name = ActiveSheet.Name Then MsgBox namedRanges.Name
Next namedRanges
End Sub
however, I just want to call a certain Names for them to do something and they are static. How do I do that?
I tried declaring the Named ranges I want but I don't think I'm doing it right.
Sub Test3()
Dim nameArr(1 To 3) As Integer
Dim vari As Variant
nameArr("Page1") = 1: nameArr("Page2") = 2: nameArr("Page3") = 3
Dim idx As Long
For idx = LBound(nameArr) To UBound(nameArr)
vari = nameArr(idx)
MsgBox vari
Next idx
End Sub
I made a variable nameArr as my static array here with the purpose for them to be the only one to do something within the for each loop.
Loop Over a List of Names