Iterating through Excel Named Ranges
Simple code to iterate through named ranges
1: Dim fm as Form
2: Dim nm As Name
3: Dim val As Double
4:
5: For Each nm In ActiveWorkbook.Names
6: 'Check MacroType and Sheet References (in Name and Value)
7: 'If (nm.MacroType < 0 And InStr(1, nm.Name, "!", vbTextCompare) = 0 And InStr(1, nm.Value, "!", vbTextCompare) = 0) Then
8: 'If (nm.MacroType < 0 And InStr(1, nm.Name, "!", vbTextCompare) = 0) Then
9: If (nm.MacroType > 0) Then
10: 'Is not a standard XIXLMMacroType (1, 2, 3)
11: frm.AddNamedRange (nm.Name & "( " & CStr(nm.Value) & " )")
12: 'frm.AddNamedRange (nm.Name & "( " & CStr(nm.MacroType) & " )")
13: End If
14: Next nm
15:
16: frm.Show
Comments
Post a Comment