Hi all
I have a form with two combo boxes, both populate from the same column. I want to amend the second combo box list to exclude the value selected on the first combo box. the column is a list of locations, the form allows two locations to be selected
<Code>Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim i As Integer
' Select "from location"
Set ws = Worksheets("Locations")
For i = 6 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row Step 1
If ws.Cells(i, 1).Value <> vbNullString Then Me.cbFromLoc.AddItem ws.Cells(i, 1).Value
Next I
' Select "To Location"
For i = 6 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row Step 1
If ws.Cells(i, 1).Value <> vbNullString Then Me.cbToLoc.AddItem ws.Cells(i, 1).Value
Next i
End Sub
</code>
Any ideas
Thanks
I have a form with two combo boxes, both populate from the same column. I want to amend the second combo box list to exclude the value selected on the first combo box. the column is a list of locations, the form allows two locations to be selected
<Code>Private Sub UserForm_Initialize()
Dim ws As Worksheet
Dim i As Integer
' Select "from location"
Set ws = Worksheets("Locations")
For i = 6 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row Step 1
If ws.Cells(i, 1).Value <> vbNullString Then Me.cbFromLoc.AddItem ws.Cells(i, 1).Value
Next I
' Select "To Location"
For i = 6 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row Step 1
If ws.Cells(i, 1).Value <> vbNullString Then Me.cbToLoc.AddItem ws.Cells(i, 1).Value
Next i
End Sub
</code>
Any ideas
Thanks