Option
Explicit
Const
C_mstrDatenblatt
As
String
=
"Tabelle1"
Const
C_mstrZielblatt
As
String
=
"Tabelle2"
Dim
mobjDic
As
Object
Dim
mlngLast
As
Long
Dim
sVar
Dim
variable
As
String
Dim
mlngZ
As
Long
Private
Sub
ComboBox1_Enter()
Set
mobjDic = CreateObject(
"Scripting.Dictionary"
)
For
mlngZ = 2
To
mlngLast
mobjDic(Worksheets(C_mstrDatenblatt).Cells(mlngZ, 1).Value) = 0
Next
Me
.ComboBox1.List = mobjDic.keys
Set
mobjDic =
Nothing
End
Sub
Private
Sub
ComboBox2_Enter()
Set
mobjDic = CreateObject(
"Scripting.Dictionary"
)
With
Worksheets(C_mstrDatenblatt)
For
mlngZ = 2
To
mlngLast
If
.Cells(mlngZ, 1).Value =
Me
.ComboBox1.Value
Then
mobjDic(.Cells(mlngZ, 2).Value) = 0
End
If
Next
End
With
Me
.ComboBox2.List = mobjDic.keys
Set
mobjDic =
Nothing
End
Sub
Private
Sub
ComboBox3_Enter()
Set
mobjDic = CreateObject(
"Scripting.Dictionary"
)
With
Worksheets(C_mstrDatenblatt)
For
mlngZ = 2
To
mlngLast
If
.Cells(mlngZ, 2).Value =
Me
.ComboBox2.Value
Then
mobjDic(.Cells(mlngZ, 3).Value) = 0
End
If
Next
End
With
Me
.ComboBox3.List = mobjDic.keys
Set
mobjDic =
Nothing
End
Sub
Private
Sub
ComboBox4_Enter()
Me
.ComboBox4.Clear
With
Worksheets(C_mstrDatenblatt)
For
mlngZ = 2
To
mlngLast
If
.Cells(mlngZ, 1).Value =
Me
.ComboBox1.Value
And
.Cells(mlngZ, 2).Value =
Me
.ComboBox2.Value
And
.Cells(mlngZ, 3).Value =
Me
.ComboBox3.Value
Then
Me
.ComboBox4.AddItem .Cells(mlngZ, 4).Value
End
If
Next
End
With
End
Sub
Private
Sub
ComboBox4_Change()
Label1.Caption = ComboBox1 &
" "
& ComboBox2 &
" "
& ComboBox3 &
" "
& ComboBox4
End
Sub
Private
Sub
CommandButton1_Click()
Unload
Me
End
Sub
Private
Sub
CommandButton2_Click()
With
Worksheets(C_mstrZielblatt)
.Cells(.Cells(Rows.Count, 1).
End
(xlUp).Row + 1, 1).Value =
Me
.ComboBox1.Value
Me
.ComboBox1.Clear
.Cells(.Cells(Rows.Count, 2).
End
(xlUp).Row + 1, 2).Value =
Me
.ComboBox2.Value
Me
.ComboBox2.Clear
.Cells(.Cells(Rows.Count, 3).
End
(xlUp).Row + 1, 3).Value =
Me
.ComboBox3.Value
Me
.ComboBox3.Clear
.Cells(.Cells(Rows.Count, 4).
End
(xlUp).Row + 1, 4).Value =
Me
.ComboBox4.Value
Me
.ComboBox4 =
" "
Label1.Caption =
" "
End
With
End
Sub
Private
Sub
UserForm_Initialize()
mlngLast = Worksheets(C_mstrDatenblatt).Cells(Rows.Count, 1).
End
(xlUp).Row
End
Sub