I have a userform with a listbox (shown below) that is populated from a spreadsheet (cc_output) generated by an advanced filter.

I am trying to write some code so that when you double click on a record in the listbox a lookup is performed on the spreadsheet (cc_output) to find the matching record and populate all of the data in some comboboxes in the userform.

I am trying to look up using the cc_id which is in the first column of the listbox and which is stored in column A of the spreadsheet cc_output.

This is working perfectly for records with cc_id 17 to 8 in the listbox but when I click on any records with cc_id 7 - 1 they return the wrong record from the spreadsheet.

That is

Double clicking cc_id 17 returns cc_id 17
Double clicking cc_id 16 returns cc_id 16

but...

Double clicking cc_id 7 returns cc_id 17
Double clicking cc_id 6 returns cc_id 16

and so on... until...

Double clicking cc_id 1 returns cc_id 17 also!


ListBox.PNG

Here is an excerpt of my code:

Sub lstSearch_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

'declare the variables
    Dim CC_ID As String
    Dim i As Integer
    Dim j As Integer
    Dim findvalue
    
'error scheduler
    On Error GoTo errHandler:
    
'get the selected value from the listbox
    j = lstSearch.ListCount - 1
    For i = 0 To j
        If lstSearch.Selected(i) = True Then
'set the listbox column
            CC_ID = lstSearch.List(i, 0)
        End If
    Next i
    
'find the value in the range
    Set findvalue = ThisWorkbook.Worksheets("cc_output").Range("A:A").Find(What:=CC_ID, LookIn:=xlValues).Offset(0, 0)
    
'add the values to the userform controls
    Me.cboID.Value = findvalue.Offset(0, 0)
    Me.cboD.Value = day(findvalue.Offset(0, 1))
    Me.cboM.Value = month(findvalue.Offset(0, 1))
    Me.cboM.Value = MonthName(cboM.Value, True)
    Me.cboY.Value = year(findvalue.Offset(0, 1))
Any ideas?