C
Carl
Is there a way to add a value of "1" to a cell by just clicking in the cell?
Thanks,
Carl
Thanks,
Carl
Dave Peterson said:Nope. There's nothing that fires when you click on a cell.
But maybe you could tie into the _beforedoubleclick and _beforerightclick
events:
If you want to try, rightclick on the worksheet tab that should have this
behavior. Select view code and paste this into the code window:
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub
Cancel = True 'stop editing in cell
If IsNumeric(Target.Value) Then
Target.Value = Target.Value + 1
End If
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub
Cancel = True 'stop pop up from showing
If IsNumeric(Target.Value) Then
Target.Value = Target.Value - 1
End If
End Sub
I used any cell in Column A. You can change that in both spots if you
want.
Doublclicking will add 1. Rightclicking will subtract 1.
You may still need the .enableevents for other reasons, but there's
nothing in
your code that causes the _selectionchange event to fire again.