davidmyers
Board Regular
- Joined
- Jan 29, 2017
- Messages
- 88
- Office Version
- 2016
- Platform
- Windows
Hi I have a couple of userforms with listbox I want to open the listbox when I double click on a cell, and when I select an item in the listbox (it's a single select), that item should be copied to the active cell and the listbox should close, I have both single column and multicolumn list boxs. This what I have at the moment:
to open the listbox.
to copy the selected item and close I have:
to open the listbox.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Application.Intersect(Target, Range("N2:N756")) Is Nothing Then
Cancel = True
UserForm1.Show
End If
If Not Application.Intersect(Target, Range("D2:D755")) Is Nothing Then
Cancel = True
UserForm3.Show
End If
End Sub
to copy the selected item and close I have:
Code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ActiveCell.Value = ListBox1.Value
GetSelectedItemsText = text
Unload Me
End Sub
[CODE]
Is there a better way to do this?
Thanks for any help
David