Bagharmin
Board Regular
- Joined
- Nov 22, 2010
- Messages
- 168
I have a ComboBox1 on a UserForm that is populated from a list of clients found on a worksheet located in the same workbook. My goal is to use the ComboBox1_Change() event to take the item selected from ComboBox1, find it on the list used to populate it, and (eventually) use that result to get additional information on the selection. However, I can't seem to find a match. Here's the code:
I keep getting an error at the "FSRFind = " line, saying it can't find a match. I'm having a hard time seeing how that can be since all the items in ComboBox1 came directly from the ClientCombos range. Can anyone tell me what simple thing I've forgotten here?
Thanks.
Code:
Private Sub ComboBox1_Change()
Dim ClientFSRs As Range, ClientCombos As Range, CB7Scan As Integer, FSRFind As Double
With Worksheets("Clients")
Set ClientFSRs = .Range(.Cells(3, 9), .Cells(.Range("C1") + 2, 9))
Set ClientCombos = .Range(.Cells(3, 4), .Cells(.Range("C1") + 2, 9))
End With
Select Case ComboBox1.ListIndex
Case Is > 2
For CB7Scan = 0 To 4
FSRFind = Application.WorksheetFunction.Match(ComboBox1.List(ComboBox1.ListIndex), ClientCombos, 0)
If ComboBox7.List(CB7Scan) = Application.WorksheetFunction.Index(ClientFSRs, FSRFind, 1) Then
ComboBox7.ListIndex = CB7Scan
Exit Sub
End If
Next CB7Scan
ComboBox7.ListIndex = 0
End Select
End Sub
I keep getting an error at the "FSRFind = " line, saying it can't find a match. I'm having a hard time seeing how that can be since all the items in ComboBox1 came directly from the ClientCombos range. Can anyone tell me what simple thing I've forgotten here?
Thanks.