Option Explicit
Private Sub ComboBox1_Change()
Me.ComboBox2.Clear
' set worksheet
Dim sh As Worksheet
Set sh = Sheets("Clients")
'declare variable
Dim i As Long
For i = 2 To sh.Range("A10000").End(xlUp).Row
If sh.Cells(i, 1) = Me.ComboBox1.Value Then
If Application.WorksheetFunction.CountIf(sh.Range("B2", "B" & i), sh.Cells(i, 2)) = 1 Then
Me.ComboBox2.AddItem sh.Cells(i, 2)
End If
End If
Next i
End Sub
Private Sub ComboBox2_Change()
Me.ComboBox3.Clear
' set worksheet
Dim sh As Worksheet
Set sh = Sheets("Clients")
'declare variable
Dim i As Long
For i = 2 To sh.Range("A10000").End(xlUp).Row
If sh.Cells(i, 2) = Me.ComboBox2.Value Then
Me.ComboBox3.AddItem sh.Cells(i, 3)
End If
Next i
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
' set worksheet
Dim sh As Worksheet
Set sh = Sheets("Clients")
'declare variable
Dim i As Long
For i = 2 To sh.Range("A10000").End(xlUp).Row
If Application.WorksheetFunction.CountIf(sh.Range("A2", "A" & i), sh.Cells(i, 1)) = 1 Then
Me.ComboBox1.AddItem sh.Cells(i, 1)
End If
Next i
End Sub
No comments:
Post a Comment