hi,

i'm working on a userform. it has a listbox. when the form starts up, it looks in column A for any cells that have something in it (starting after row 2).

for each cell that has something in it, a line is added to the listbox. the line added in the listbox is whatever the value of the cell and the cell one column right of it was.

here's the code:

Private Sub UserForm_Initialize()

With Range("A:A")
    For Each r In Range("A:A")
    If Not r.Value = 0 And r.Row > 2 Then
    ListBox1.AddItem r.Value & " " & r.Offset(0, 1).Value, -1
    End If
    Next
End With
    
    ListBox1.ListIndex = ListBox1.ListCount - 1
    
End Sub
now, i'm trying work on code that will make it so that when i click on a line in the listbox, the corresponding cell in row A will be selected. but i don't know how to do this. any ideas?

thankyou