I have a combobox that the user selects a location from. Based on the location selected I have a second combobox that the user can select an equipment ID from and then a third combobox that the user can select a task from. Everything is working ok except for the second combobox. It populates the equipment IDs but has duplicates. I would like to remove the duplicates. Any help would be appreciated. Thank you.
Here is the code I am using for the second combobox:
Private Sub TASKS_LOCATION_SELECT_BOX_DropButtonClick()
'*********************************************************************************************************************
'This routine looks at the Location selected and populates the Equip ID combobox with ID's set to that Location.
'*********************************************************************************************************************
TASKS_EQUIP_ID_LIST.Clear 'Clears old entries from list.
Dim txtVal As String
If IsNull(Me.TASKS_LOCATION_SELECT_BOX.value) = False Then 'Looks at selected Location.
txtVal = Me.TASKS_LOCATION_SELECT_BOX.value
Else
txtVal = ""
End If
Dim rng As Range
Set rng = ThisWorkbook.Sheets("Task Due Dates").Range("C2:C750") 'Where to look for Location.
Dim rCell As Range
For Each rCell In rng.Cells 'Check each cell in range.
If rCell.value = txtVal Then 'If cell contains a Location.
With Me.TASKS_EQUIP_ID_LIST
.AddItem rCell.Offset(0, -2).value 'Add Equip ID to list.
End With
End If
Next rCell 'Check each cell.
End Sub
Here is my spreadsheet:
Here is the code I am using for the second combobox:
Private Sub TASKS_LOCATION_SELECT_BOX_DropButtonClick()
'*********************************************************************************************************************
'This routine looks at the Location selected and populates the Equip ID combobox with ID's set to that Location.
'*********************************************************************************************************************
TASKS_EQUIP_ID_LIST.Clear 'Clears old entries from list.
Dim txtVal As String
If IsNull(Me.TASKS_LOCATION_SELECT_BOX.value) = False Then 'Looks at selected Location.
txtVal = Me.TASKS_LOCATION_SELECT_BOX.value
Else
txtVal = ""
End If
Dim rng As Range
Set rng = ThisWorkbook.Sheets("Task Due Dates").Range("C2:C750") 'Where to look for Location.
Dim rCell As Range
For Each rCell In rng.Cells 'Check each cell in range.
If rCell.value = txtVal Then 'If cell contains a Location.
With Me.TASKS_EQUIP_ID_LIST
.AddItem rCell.Offset(0, -2).value 'Add Equip ID to list.
End With
End If
Next rCell 'Check each cell.
End Sub
Here is my spreadsheet:
Equip ID | Task ID | Location |
R501 | T101 | REVLIS 2 |
R400 | T202 | REVLIS 4 |
R300 | T101 | REVLIS 3 |
R300 | T105 | REVLIS 3 |
R400 | T107 | REVLIS 4 |
R303 | T105 | AKROCHEM |
R303 | T107 | AKROCHEM |
R305 | T107 | REVLIS 3 |
R400 | T106 | REVLIS 4 |
R501 | T105 | REVLIS 2 |