re-enabling the double click

M

mark kubicki

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?
 
J

Jan Karel Pieterse

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
 
M

mark kubicki

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?
 
D

Dick Kusleika

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
 
M

mark kubicki

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top