AW: Du hast nur EINE Dynamik
17.08.2009 10:46:32
Hajo_Zi
Hallo Boris,
das hatte ich übersehen.
Hallo Kay,
schreibe unter die Tabelle folgenden Code.
Option Explicit
Private Sub Worksheet_Activate()
'* 11.06.09 *
'* erstellt von Karin, http://beverly.excelhost.de*
'* beverly@excelhost.de *
Dim InSpalte As Integer
Dim arrNamen()
Dim loStart As Long
Dim loZeile As Long
Dim inNamen As Integer
With ThisWorkbook.Worksheets("Data")
For loZeile = 1 To IIf(IsEmpty(.Cells(.Rows.Count, 1)), .Cells(.Rows.Count, 1).End(xlUp) _
.Row, .Rows.Count)
If .Cells(loZeile, 1) "" Then
ReDim Preserve arrNamen(0 To inNamen)
arrNamen(inNamen) = .Cells(loZeile, 1)
inNamen = inNamen + 1
End If
Next loZeile
loStart = 1
For InSpalte = 1 To IIf(IsEmpty(.Cells(1, .Columns.Count)), .Cells(1, .Columns.Count). _
End(xlToLeft).Column, .Columns.Count)
If .Cells(1, InSpalte) "" Then
On Error Resume Next
ThisWorkbook.Names(.Cells(1, InSpalte)).Delete
On Error GoTo 0
ThisWorkbook.Names.Add .Cells(1, InSpalte), RefersTo:=.Range(.Cells(2, InSpalte) _
, .Cells(IIf(IsEmpty(.Cells(.Rows.Count, InSpalte)), .Cells(.Rows.Count, InSpalte).End(xlUp).Row, .Rows.Count), InSpalte))
End If
Next InSpalte
End With
End Sub
Gruß Hajo