Hi,
I'm trying to make a userform to display data from a worksheet previously entered.
I need two keys for finding the right data, "Datum" and "Winkel".
I have this code that almost works, but my problem is that I have to make de Array formula dynamic filled with values from ComboBox1 and ComboBox2 and
I really don't know how to do that.
here is the code that has to be changed:
Rw = Evaluate("MATCH(b7&a9,data_datum&data_winkel,0)+1")
B7 has to be the value from ComboBox1
A9 has to be the value from ComboBox2
Here is the complete code:
Dim rComboSource As Range
Private Sub ComboBox1_Change()
Dim Col As Long
With Me
Col = .ComboBox1.ListIndex + 1
With Blad1
Set rComboSource = .Range(.Cells(2, 2), .Cells(10, 2))
End With
.ComboBox2.Clear
.ComboBox2.List = rComboSource.Value
End With
End Sub
Private Sub ComboBox2_Change()
Dim Rw As Long
Dim sModel As String
Const fmt As String = "Currency"
sModel = Me.ComboBox2.Value
With Blad1
If sModel = vbNullString Then Exit Sub
Rw = Evaluate("MATCH(b7&a9,data_datum&data_winkel,0)+1")
If Rw < 1 Then Exit Sub
Me.TextBox1.Value = Format(.Cells(Rw, 3).Value, fmt)
Me.TextBox2.Value = Format(.Cells(Rw, 4).Value)
Me.TextBox3.Value = Format(.Cells(Rw, 5).Value)
End With
End Sub
Private Sub UserForm_Activate()
Dim cl As Range
With Blad1
Set rComboSource = .Range(.Cells(2, 1), .Cells(10, 1))
For Each cl In rComboSource
Me.ComboBox1.AddItem cl.Value
Next cl
End With
End Sub
Bookmarks