ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   re-enabling the double click (https://www.excelbanter.com/excel-programming/297928-re-enabling-double-click.html)

Mark Kubicki

re-enabling the double click
 
if I evaluate a range of cells using the "beforeDoubleClick" event, I can
set the cancel argument to True, disabling the event.

problem is that I don't always want that condition; for example, so that the
user can perform in-cell editing with cells in that same range, they should
be able to DoubleClick within the active cell (selected/activated by a
single Click) with would start the editing. ...However, the cancel argument
of the double click disabled that possibility...

how do I turn it back on?



Jan Karel Pieterse

re-enabling the double click
 
Hi Mark,

problem is that I don't always want that condition; for example, so that the
user can perform in-cell editing with cells in that same range, they should
be able to DoubleClick within the active cell (selected/activated by a
single Click) with would start the editing. ...However, the cancel argument
of the double click disabled that possibility...


By telling VBA when to cancel and when not:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Me.Range("A1:B2"), Target) Is Nothing Then
MsgBox "Editing allowed"
Else
MsgBox "Editing blocked in A1:B2"
Cancel = True
End If
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com


Mark Kubicki

re-enabling the double click
 
not quite...i understand that part,

the conflict is that in A1:B2, i only want to disable the double click to a
currently (before the dbl clickevent)
inactive cell
but,
if the cell is already active -thru a "click" event (not a "double click"),
the "double click event" needs to be enabled for the user to initiate
in-cell editing (without using the F2 option) (however, the double click has
previously been disabled


can i do something like:
beforeDoubleClick
if intersect, and cell has not been active
or
restore DoubleClick argument for cancel to false for all the cells?


"Jan Karel Pieterse" wrote in message
...
Hi Mark,

problem is that I don't always want that condition; for example, so that

the
user can perform in-cell editing with cells in that same range, they

should
be able to DoubleClick within the active cell (selected/activated by a
single Click) with would start the editing. ...However, the cancel

argument
of the double click disabled that possibility...


By telling VBA when to cancel and when not:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Me.Range("A1:B2"), Target) Is Nothing Then
MsgBox "Editing allowed"
Else
MsgBox "Editing blocked in A1:B2"
Cancel = True
End If
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com




Dick Kusleika[_3_]

re-enabling the double click
 
Mark

This is pretty kludgy, but here's what I came up with. In a standard
module, put this

Public bNewlyActive As Boolean

Sub ResetNew()

bNewlyActive = False

End Sub

In your sheet module, put this

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)

If bNewlyActive Then
MsgBox "Dclicked an inactive cell"
Else
MsgBox "Dclicked an active cell"
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

bNewlyActive = True

Application.OnTime Now + TimeValue("00:00:01"), "ResetNew"

End Sub

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"mark kubicki" wrote in message
...
not quite...i understand that part,

the conflict is that in A1:B2, i only want to disable the double click to

a
currently (before the dbl clickevent)
inactive cell
but,
if the cell is already active -thru a "click" event (not a "double

click"),
the "double click event" needs to be enabled for the user to initiate
in-cell editing (without using the F2 option) (however, the double click

has
previously been disabled


can i do something like:
beforeDoubleClick
if intersect, and cell has not been active
or
restore DoubleClick argument for cancel to false for all the cells?


"Jan Karel Pieterse" wrote in message
...
Hi Mark,

problem is that I don't always want that condition; for example, so

that
the
user can perform in-cell editing with cells in that same range, they

should
be able to DoubleClick within the active cell (selected/activated by a
single Click) with would start the editing. ...However, the cancel

argument
of the double click disabled that possibility...


By telling VBA when to cancel and when not:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Me.Range("A1:B2"), Target) Is Nothing Then
MsgBox "Editing allowed"
Else
MsgBox "Editing blocked in A1:B2"
Cancel = True
End If
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com






Mark Kubicki

re-enabling the double click
 
kludgy is ok...
thanks a million... (i wasn't even certain that i was able to correctly
communicate the dilemma)
mark

"Dick Kusleika" wrote in message
...
Mark

This is pretty kludgy, but here's what I came up with. In a standard
module, put this

Public bNewlyActive As Boolean

Sub ResetNew()

bNewlyActive = False

End Sub

In your sheet module, put this

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)

If bNewlyActive Then
MsgBox "Dclicked an inactive cell"
Else
MsgBox "Dclicked an active cell"
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

bNewlyActive = True

Application.OnTime Now + TimeValue("00:00:01"), "ResetNew"

End Sub

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"mark kubicki" wrote in message
...
not quite...i understand that part,

the conflict is that in A1:B2, i only want to disable the double click

to
a
currently (before the dbl clickevent)
inactive cell
but,
if the cell is already active -thru a "click" event (not a "double

click"),
the "double click event" needs to be enabled for the user to initiate
in-cell editing (without using the F2 option) (however, the double click

has
previously been disabled


can i do something like:
beforeDoubleClick
if intersect, and cell has not been active
or
restore DoubleClick argument for cancel to false for all the cells?


"Jan Karel Pieterse" wrote in message
...
Hi Mark,

problem is that I don't always want that condition; for example, so

that
the
user can perform in-cell editing with cells in that same range, they

should
be able to DoubleClick within the active cell (selected/activated by

a
single Click) with would start the editing. ...However, the cancel

argument
of the double click disabled that possibility...


By telling VBA when to cancel and when not:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel

As
Boolean)
If Intersect(Me.Range("A1:B2"), Target) Is Nothing Then
MsgBox "Editing allowed"
Else
MsgBox "Editing blocked in A1:B2"
Cancel = True
End If
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com









All times are GMT +1. The time now is 12:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com