Before_Double_Click Event

P

Paul Menhennett

I have some code that toggles between two values (Yes/No) when the user
double clicks the cell. The problem is, it only works once, then you have to
leave the cell and come back for it to work again. Is there a programmatic
way to reset the cell to the predouble click state so it will accept this
event again. I have tried activating another cell and then reactivating this
cell but it does no good. And another question. Why are there so few events?
No click events no mouse up,down, move and cells are not objects.
Thanks
 
G

Gary''s Student

Remember to Cancel (editting) in the flip-flop:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
If Target.Value = "yes" Then
Target.Value = "no"
Cancel = True
Exit Sub
End If
Target = "yes"
Cancel = True
End Sub
 
D

Dave Peterson

I've never seen that happen.

Maybe you're not doubleclicking fast enough or maybe even too fast.

This worked for me:

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
MsgBox "hi"
Cancel = True 'stop the editing in cell
End Sub

If this doesn't help, you may want to share your procedure.
 
P

Paul Menhennett

Thank you.
Solved my problem.

Gary''s Student said:
Remember to Cancel (editting) in the flip-flop:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
If Target.Value = "yes" Then
Target.Value = "no"
Cancel = True
Exit Sub
End If
Target = "yes"
Cancel = True
End Sub
 

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