Re: Auf Bereichsnamen mit VBA zugreifen
18.07.2002 10:37:13
MAlexander
Moin, Lukas.Was jetzt folgt, sind nur Denkanstöße:
1. Namen herausfinden
Sub ListAllNames(InBereich)
Dim nms As Names
Dim x As Long
Dim ZielZeile As Long
Dim ZielSpalte As Byte
ZielZeile = InBereich.Row
ZielSpalte = InBereich.Column
Set nms = ActiveWorkbook.Names
With Worksheets(InBereich.Parent.Name)
For x = 1 To nms.Count
.Cells(ZielZeile, ZielSpalte).Value = nms(x).Name
.Cells(ZielZeile, ZielSpalte + 1).Value = Mid(nms(x).RefersTo, 2)
ZielZeile = ZielZeile + 1
Next
End With
End Sub
2. Zugriff auf Bereiche (A1:B20 heißt "HugoHugo")
dim Hugo as range
dim Zelle as range
dim Wert as string
set Hugo = range("HugoHugo")
for each Zelle in Hugo ' Das ist ja fast schon Biologie
Zelle.value = "Krebs"
wert = Zelle.value
next
3. Anzahl Spalten: Hugo.columns.count
4. Anzahl Zeilen: Hugo.rows.count
MAlexander