Disable Doubleclick

  • Thread starter Thread starter Brandon
  • Start date Start date
B

Brandon

I am trying to disable the mouse doubleclick on certain
cells(range) of a spreadsheet. I know how to disable
doubleclicking for the entire spreadsheet using:

Application.EditDirectlyInCell = False

Is there a way apply this to a specific range only?
 
In the BeforeDoubleClick event of the Worksheet:

If Not Intersect(Target, Range("A1:D4")) Is Nothing Then Cancel = True
 
Brandon,

In the Workbook code:

Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target
As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A1")) Is Nothing Then Cancel = True
End Sub

This is for doubleclick only, it doesn't prevent a user from editting
directly in the formula bar.

Rob
 
Brandon,

Try this....Doubleclick disabled for range A1:B3 only
(modify to suit)

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Target, Range("A1:B3")) Is Nothing Then
Application.EditDirectlyInCell = False
Cancel = True
Application.EditDirectlyInCell = True
End If
End Sub

John
 
Brandon,

Vasant's and Rob's answers are a lot less overkill.
Use what they gave you instead of what I gave you.

John
 
Thank you all for your answers. I tried them all and they
worked.
I used the following code from Patrick Molloy and it
disabled the doubleclick for the range of cells from A1
to A10.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As
Range, Cancel As Boolean)
Cancel = Not (Intersect(Target, Range("A1:A10")) Is
Nothing)
End Sub

Thanks a lot to all of you,
Brandon
 
Back
Top