Double click to add one

-emma-

Board Regular
Joined
Jul 14, 2006
Messages
180
Office Version
  1. 365
Platform
  1. Windows
Hi everyone and thanks for your time :)

I am hoping someone can help me out with what I need - I dont really know where to start with these things...

What I want sounds easy but I am clueless!

Within the range C4:G26 each cell has a number in it. What I need is when a certain cell is double clicked on, the number in that call increases by 1.

For example, C6 has the number 5 in it. When I double click within C6, the number increases to 6.

Any suggestions welcome - Thank you!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
This requires VBA.

Put this code into the module for the sheeting containing the range you mentioned.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

   If Not Intersect(Target, Range("C4:G26")) Is Nothing Then
      Cancel = True
      Target = Target + 1
   End If

End Sub
 
Upvote 0
How about
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Not Intersect(Target, Range("C4:G26")) Is Nothing Then
      Target.Value = Target.Value + 1
      Cancel = True
   End If
End Sub
 
Upvote 0
Hi,

Use below code on Worksheet Before Double Click event:

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
If Not Intersect(Target, Range("C4:G26")) Is Nothing Then
    Target.Value = Target.Value + 1
End If
End Sub
 
Upvote 0
Personally I would recommend putting the Cancel=Trueinside the If like Jeff & I did. Otherwise you are preventing the user from going into edit mode.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top