Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to double click a cell and add 1 to that cell value in Excel?

This article will show you method of add 1 to a cell value automatically with double clicking it in Excel.

Double click a cell and add 1 with VBA code


arrow blue right bubble Double click a cell and add 1 with VBA code


The following VBA code can help you add 1 to a cell value after double clicking. Please do as follows.

1. Right click the sheet tab which the cell values you need to add 1 with double clicking. Then click View Code from the right-clicking menu.

2. In the popping up Microsoft Visual Basic for Applications window, copy and paste the below VBA code into the Code window.

VBA code: Add 1 to a cell value with double clicking

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    If Not Intersect(Target, Range("A1")) Is Nothing Then
      Range("A1").Value = Range("A1").Value + 1
      Cancel = True
    End If
End Sub

Note: In the code, A1 is the cell you will add number 1 to with double clicking.

3. Press the Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window.

Now, double click on cell A1 will add 1 to the existing value as below screenshot shown.


arrow blue right bubbleRelated articles:


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Bill Oertell · 1 years ago
    If you want to increment any cell in a workbook cell by double clicking on that cell but only that cell, this code works:

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    On Error Resume Next
    If Not Intersect(Target, Range(ActiveCell.Address)) Is Nothing Then
    ActiveCell.Value = ActiveCell.Value + 1
    Cancel = True
    End If
    End Sub
  • To post as a guest, your comment is unpublished.
    Steve · 1 years ago
    This is great! How do I do this for multiple cells? I type in "A1,A2" instead "A1", it makes both cells equal and adds 1 to both cells simultaneously. I'd like the cells to act independently.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Sorry I didn’t get your point.
      • To post as a guest, your comment is unpublished.
        Adam · 1 years ago
        Hello - agree with Steve this is great. I think what he would like (and me too) is to be able to add to the value of multiple different cells in the same tab by double clicking on them. He has amended the VBA formula so it says "A1,A2" instead of just "A1" however double clicking on "A1" adds 1 to both cells. Is it possible to change the formula so that multiple cells are included with the value of each only being increased when you click on it directly?
        • To post as a guest, your comment is unpublished.
          laura · 1 years ago
          maybe by making a table with a range name. and updating the formula to include that?
        • To post as a guest, your comment is unpublished.
          Steve · 1 years ago
          Basically, with the code above, if you double clicked on A1, it would add 1 to A1. If I changed A1 to A1:A2 in the Target Range, then if I double clicked on A1 or A2, it would add 1 to A1. What I wanted was to add 1 to A1 only if I double clicked on A1, and add 1 to A2 only if I double clicked on A2. I also did not want to add 1 to both cells.

          I think I have found what I was looking for:

          Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
          If Not Intersect(Target, Range("D5:BC56")) Is Nothing Then
          Cancel = True
          Range(Target.Address).Value = Val(Range(Target.Address).Value) + 1
          End If
          End Sub
          • To post as a guest, your comment is unpublished.
            Sophie · 11 months ago
            This code does not seem to work for me. Don't I have to specify which is the Target.Adress ?
          • To post as a guest, your comment is unpublished.
            crystal · 1 years ago
            Dear Steve,
            I got your point finally, and thank you for sharing.
  • To post as a guest, your comment is unpublished.
    Matt · 1 years ago
    Can we add a two digit number to the end of the date? for example i need to double click and add the current date and the next two digit number (20171030-01 then the next cell will show 20171030-02 upon double click)
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Dear Matt,
      The code only supports the number format cell. It can't work as your data 20171030-01 is text format. Sorry about that.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Dear Matt,
      The code only supports the number format cell. It can work as your data 20171030-01 is a text format. Sorry about that.