Schleife durch die benannten Bereiche der Arbeitsmappe; Überprüfen Sie, ob sich jeder Name auf einen Bereich in diesem Arbeitsblatt bezieht und dass sich der benannte Bereich auf einen Bereich bezieht, der sich mindestens teilweise in der ersten Zeile befindet.
Dim n As Long, vColNames As Variant
Dim c As Long, twb As Workbook
Set twb = ThisWorkbook
With Worksheets("Sheet1")
With .Cells(1, 1).CurrentRegion
'dim the array one-based to parallel the columns
ReDim vColNames(1 To .Columns.Count)
'loop through all names looking for ones that intersect first row
For n = 1 To twb.Names.Count
'check the parent worksheet first
If twb.Names(n).RefersToRange.Parent.Name = .Parent.Name Then
' next check to ensure first row is part of named range
If Not Intersect(twb.Names(n).RefersToRange, .Rows(1), .Cells) Is Nothing Then
vColNames(Intersect(twb.Names(n).RefersToRange, .Rows(1)).Cells(1, 1).Column) = _
twb.Names(n).Name
End If
End If
Next n
End With
End With
For c = LBound(vColNames) To UBound(vColNames)
Debug.Print vColNames(c)
Next c
Namen mit Arbeitsmappe Umfang kommt heraus als myNamedRange; Diese mit Arbeitsblattbereich werden in Form von Sheet1! myNamedRange.
Was meinst du namesbox? Könnten Sie einen Screenshot posten und weitere Details angeben? – Will
@Will - Ich nehme das als * benannte Bereiche * mit der * Namensbox * links von der Bearbeitungsleiste. – Jeeped