List box only returns last entry...

chipsworld

Board Regular
Joined
May 23, 2019
Messages
121
Office Version
  1. 365
Hi all,
Need some help. I have done this many times before, but for some reason, when I double click on a line item in the list box, it will only return the last entry into the sheet.

I know I am missing something, but can't for the life of me, see what it is...

Any help would be greatly appreciated.

Here is the code as is...

VBA Code:
Private Sub lstmain_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

Dim wsform As Worksheet

Set wsform = ThisWorkbook.Worksheets("Historical")


With wsform

    If Me.lstmain.ListIndex = -1 Then    'not selected
            MsgBox " Please make a selection!"
        ElseIf Me.lstmain.ListIndex >= 0 Then    'User has selected
            r = Me.lstmain.ListIndex
            With frminput
                .txtIDNum.Value = lstmain.List(r, 0)
                .txtSYmp.Value = lstmain.List(r, 1)
                .txtscribe.Value = lstmain.List(r, 2)
                .txtoper.Value = lstmain.List(r, 3)
                .txttestdat.Value = lstmain.List(r, 4)
                .txttime.Value = lstmain.List(r, 5)
                .txtname.Value = lstmain.List(r, 6)
                .txtdob.Value = lstmain.List(r, 7)
                .txtorg.Value = lstmain.List(r, 8)
                .txtrole.Value = lstmain.List(r, 9)
                .txtphone.Value = lstmain.List(r, 10)
                .cmbresult.Value = lstmain.List(r, 11)
                .cmbcontrol.Value = lstmain.List(r, 12)
                .txtkitnum.Value = lstmain.List(r, 13)
                .txtexpdat.Value = lstmain.List(r, 14)
   
           
            End With
           
        Unload Me
   
   
        With Application
            xLeft = .Left + 0.5 * .Width
            xTop = .Top + 0.5 * .Height
        End With
   
        With frminput
           
            .Left = xLeft - 0.5 * .Width
            .Top = xTop - 0.5 * .Height
            .Show
        End With


End If
End With

End Sub

Update...when double clicking an entry, it will work most of the time, but every 3rd or 4th time, it will return the entry selected, but with the wrong name in that field..
 
Last edited by a moderator:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,136,290
Messages
5,674,887
Members
419,532
Latest member
longphamtel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top