double click opens userform with listbox, how to stop same dbl click causing listbox selection

davidmyers

Board Regular
Joined
Jan 29, 2017
Messages
88
Office Version
  1. 2016
Platform
  1. Windows
Hi, I have a userform which opens when I double click a cell
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Application.Intersect(Target, Range("G2:G501")) Is Nothing Then
        Cancel = True
        UserForm1.Show
    End If
End Sub


My problem is that the userform has a listbox, and if I click on a cell that's in the area that the userform will occupy then the double click that opens the userform also selects an item in the listbox.
How can I stop this happening?
Thanks for any help
David
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Check of the userform is already open and if it is, do nothing.

Code:
if userform1.visible = true then
exit sub
else
'do whaetver
endif
 
Upvote 0
Thanks for the reply Roderick, this doesn't seem to help - same problem. Where should I put this code?
I put:

Code:
    If Not Application.Intersect(Target, Range("G2:G501")) Is Nothing Then
        Cancel = True
        UserForm1.Show
         Exit Sub
    End If

Is that what you meant?

Thanks
David
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

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
Back
Top