Private
Sub
Test()
Call
Spalten_Automatisiert_umstellen(Tabelle2,
"Grün"
,
"Rot"
,
"Blau"
,
"Gelb"
)
End
Sub
Public
Sub
Spalten_Automatisiert_umstellen(
ByVal
wsTab
As
Worksheet,
ParamArray
Data()
As
Variant
)
Dim
lngI
As
Long
Dim
Letzte
As
Long
With
wsTab
Letzte = .Cells(Rows.Count, 1).
End
(xlUp).Row
For
lngI = LBound(Data)
To
UBound(Data)
ActiveSheet.Columns(SpaltenName(Data(lngI))).Copy Destination:=.Cells(Letzte + 1, lngI + 1)
Next
lngI
End
With
End
Sub
Public
Function
SpaltenName(
ByVal
Spalte
As
Variant
)
As
Variant
Dim
rng
As
Range
If
IsNumeric(Spalte)
Then
SpaltenName = Spalte
Else
Set
rng = Range(Cells(1, 1), Cells(1, Columns.Count)).Find(What:=Spalte, LookIn:=xlValues, LookAt:=xlWhole)
If
Not
rng
Is
Nothing
Then
SpaltenName = Split(rng.Address(, 0),
"$"
)(0)
End
If
End
If
End
Function