Hi,
I have been trying to search for the correct codes in my List Box double Click () for the userform that I have interfaced but to no avail.
Would appreciate if some one can help me with the following:
1) List Box to select item code from Database worksheet
2) Msgbox to indicate the item code number when selected
3) Textboxes and option button to populate from list box selection
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim iRow As Long
Dim rng As Range
Dim ws As Worksheet
Set ws = Worksheets("Database")
' find the correct row to draw data from, based on
' the item code selected
''iRow = ws.Cells(Rows.Count, 1) _
'' .End(xlUp).Offset(1, 1).Row
iRow = ws.Cells.Find(What:=Me.ListBox1, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
LookIn:=xlValues, MatchCase:=True).Row
'check for a item code
If ListBox1.Value = False Then
'If ListIndex is -1, nothing selected
MsgBox "Nothing was selected!"
Else
'If ListIndex not -1 inform user what was selected
MsgBox "You selected " & ListBox1.Value, vbOKCancel
If MsgResponse = Ok Then
' display the result in the text box
Me.TextBox3.Value = ws.Cells(iRow, 2).Value
Me.TextBox4.Value = ws.Cells(iRow, 3).Value
Me.TextBox5.Value = ws.Cells(iRow, 4).Value
Me.TextBox7.Value = ws.Cells(iRow, 5).Value
Me.TextBox8.Value = ws.Cells(iRow, 6).Value
Me.TextBox6.Value = ws.Cells(iRow, 7).Value
Me.TextBox9.Value = ws.Cells(iRow, 8).Value
Me.TextBox10.Value = ws.Cells(iRow, 10).Value
End If
End If
End Sub
Also, when I double click the output doesn't select the data instead displaying the labels
Bookmarks