Is there a was to send a left click selection of a listbox to a form?
Using the code below, a user right clicks on listbox1 and is presented with a form to add/remove (and further options) the list box item. Making the selection in userform1 returns them to the main userform and the item is now selected. This works perfectly.
The code does work with left click, however on return to the form, the list item is not selected.
Any ideas or tweaks?
Thanks
Using the code below, a user right clicks on listbox1 and is presented with a form to add/remove (and further options) the list box item. Making the selection in userform1 returns them to the main userform and the item is now selected. This works perfectly.
The code does work with left click, however on return to the form, the list item is not selected.
Code:
Private Sub ListBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim L As Long
If Button = 2 OR Button = 1 Then
L = ListBox1.TopIndex + Int(Y / (ListBox1.Font.Size * 1.2))
ListBox1.ListIndex = L
Userform1.INDEX.Value = L
Userform1.show
End If
End Sub
Thanks