AW: Bitte Beispielmappe bereitstellen - o.T.
20.08.2020 13:48:53
Nepumuk
Hallo Tim,
teste mal:
Option Explicit
Private mblnNoEvent As Boolean
Private Sub ComboBox_Marke_Change()
If Not NoEvent Then
ComboBox_Typ.Text = ComboBox_Typ.List(ComboBox_Marke.ListIndex)
TextBox_Farbe.Value = Worksheets("Daten").Cells(ComboBox_Marke.ListIndex + 2, 11).Text
End If
End Sub
Private Sub ComboBox_Typ_Change()
If Not NoEvent Then
ComboBox_Marke.Text = ComboBox_Marke.List(ComboBox_Typ.ListIndex)
TextBox_Farbe.Value = Worksheets("Daten").Cells(ComboBox_Typ.ListIndex + 2, 11).Text
End If
End Sub
Private Sub CommandButton1_Click()
Call Unload(Object:=Me)
End Sub
Private Sub TextBox_Farbe_Change()
Dim objCell As Range
If TextBox_Farbe.TextLength > 0 Then
Set objCell = Worksheets("Daten").Columns(11).Find(What:=TextBox_Farbe.Text & "*", _
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not objCell Is Nothing Then
NoEvent = True
ComboBox_Typ.Text = ComboBox_Typ.List(objCell.Row - 2)
ComboBox_Marke.Text = ComboBox_Marke.List(objCell.Row - 2)
NoEvent = False
Set objCell = Nothing
Else
NoEvent = True
ComboBox_Typ.ListIndex = -1
ComboBox_Marke.ListIndex = -1
NoEvent = False
End If
Else
NoEvent = True
ComboBox_Typ.ListIndex = -1
ComboBox_Marke.ListIndex = -1
NoEvent = False
End If
End Sub
Private Sub UserForm_Initialize()
Dim lngLastRow As Long
With Worksheets("Daten")
lngLastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
ComboBox_Typ.List = .Range(.Cells(2, 1), .Cells(lngLastRow, 1)).Value2
ComboBox_Marke.List = .Range(.Cells(2, 10), .Cells(lngLastRow, 10)).Value2
End With
End Sub
Private Property Get NoEvent() As Boolean
NoEvent = mblnNoEvent
End Property
Private Property Let NoEvent(ByVal pvblnNoEvent As Boolean)
mblnNoEvent = pvblnNoEvent
End Property
Gruß
Nepumuk