Cyril Beki
Board Regular
- Joined
- Sep 18, 2021
- Messages
- 57
- Office Version
- 2016
- Platform
- Windows
Hello Expert,
I have dependent combo box. The code works fine until i found out there's blank at end of list (Refer image for references) . How can i get rid of it ?
Below is the code i used for dependent combobox
I have dependent combo box. The code works fine until i found out there's blank at end of list (Refer image for references) . How can i get rid of it ?
Below is the code i used for dependent combobox
VBA Code:
Private Sub txtSection_Change()
Me.txtMachine.Clear
Me.txtTube.Clear
'Set Worksheet
Dim sh As Worksheet
Set sh = Sheets("Machine Problems")
'Declare Variable
Dim i As Long
For i = 2 To sh.Range("A10000").End(xlUp).Row
If sh.Cells(i, 1) = Me.txtSection.Value Then
'Removing Duplicate Value
If Application.WorksheetFunction.CountIf(sh.Range("B2", "B" & i), sh.Cells(i, 2)) = 1 _
Or Application.WorksheetFunction.CountIf(sh.Range("C2", "C" & i), sh.Cells(i, 3)) = 1 Then
Me.txtMachine.AddItem sh.Cells(i, 2)
Me.txtTube.AddItem sh.Cells(i, 3)
End If
End If
Next i
End Sub