Sub
Dropdownliste_erzeugen()
Dim
gültigliste
As
String
Dim
i
As
Long
Dim
letzte
As
Long
Dim
test
As
Boolean
If
Sheets(
"Steuerungstabelle"
).Range(
"G3"
).Value =
"A"
Then
With
Sheets(
"Analysedaten"
)
gültigliste =
","
letzte = .Cells(Rows.Count, 1).
End
(xlUp).Row
For
i = 2
To
letzte
If
.Cells(i, 1) <>
""
And
IsNumeric(.Cells(i, 1))
Then
If
InStr(1, gültigliste,
","
& .Cells(i, 1) &
","
, vbTextCompare) = 0
Then
gültigliste = gültigliste &
CLng
(.Cells(i, 1)) &
","
End
If
Next
i
End
With
If
gültigliste <>
","
Then
gültigliste = Mid(gültigliste, 2, Len(gültigliste) - 2)
gültigliste = BubbleSort(gültigliste)
With
Sheets(
"Steuerungstabelle"
).Range(
"G5"
).Validation
.Delete
.Add Type:=xlValidateList, Formula1:=gültigliste
End
With
End
If
ElseIf
Sheets(
"Steuerungstabelle"
).Range(
"G3"
).Value =
"B"
Then
With
Sheets(
"Analysedaten"
)
gültigliste =
","
letzte = .Cells(Rows.Count, 1).
End
(xlUp).Row
For
i = 2
To
letzte
If
.Cells(i, 5) <>
""
And
IsNumeric(.Cells(i, 5))
Then
If
InStr(1, gültigliste,
","
& .Cells(i, 5) &
","
, vbTextCompare) = 0
Then
gültigliste = gültigliste &
CLng
(.Cells(i, 5)) &
","
End
If
Next
i
End
With
If
gültigliste <>
","
Then
gültigliste = Mid(gültigliste, 2, Len(gültigliste) - 2)
gültigliste = BubbleSort(gültigliste)
With
Sheets(
"Steuerungstabelle"
).Range(
"G5"
).Validation
.Delete
.Add Type:=xlValidateList, Formula1:=gültigliste
End
With
test =
False
End
If
End
If
End
Sub