VBA-Dropdown Probleme
22.08.2016 16:48:32
Hans-Jörg
Bin gerade dabei einen Code zu schreiben um eine Dropdown-Liste, welche von einer anderen Dropdown-Liste abhängig ist, zu erstellen. Habe mich jetzt "festgeschrieben" und keine Ahnung mehr, wie ich weiter kommen soll.
Der momentane Code sieht so aus:
Sub dropdown()
If Range("E2") = "E-Engineering" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$N$4:$N$9"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("E2") = "SW-Engineering" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$P$4"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("E2") = "M-Engineering" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$R$4:$R$11"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("E2") = "PLT" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$T$4"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("E2") = "Dokumentation/Schulung" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$V$4"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("E2") = "Typentest/Zulassung" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$X$4:$X10$"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("E2") = "FW-Engineering" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$Z$4:$Z$8"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
ElseIf Range("E2") = "Alle" Then
Cells(5, 3).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Basisdaten!$AB$4:$AB$29"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
End Sub
In E2 befindet sich die andere Dropdown-Liste. Der code könnte auch kompletter Stuss sein...aber das kann ich leider nicht beurteilen.
Nun zu dem Problem: Es läuft, gibt keine Fehler, aber die Dropdown Liste verändert sich nicht so wie ich das will. Egal was ich in E2 auswähle, die Liste bleibt die Selbe.
Ich hoffe ihr könnt mir schnell weiter helfen.
MfG,
HJ