Excel - increase value at mouse click

In summary, the conversation discusses using VB code in Excel to increment the value in cell C8 every time cell C9 is clicked. The suggested solution involves using the Worksheet_BeforeDoubleClick function and setting Cancel to True to prevent the cell from going into edit mode. Alternatively, a link or button in cell C9 can be used for this purpose.
  • #1
atferrari
8
0
I forgot long time ago the little I knew of VB applied to Excel.

Can anyone give a snippet of VB code to get the value in cell C8 to increasing by n every time I click the mouse on cell C9?

I recall that being possible but I am clueless now.

Gracias for any help.
 
Computer science news on Phys.org
  • #2
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target = Range("C9") Then
        Range("C8").Value = Range("C8").Value + 1
        Cancel = True
    End If
End Sub

This works on double click. Setting Cancel to True prevents the cell from going into edit mode, so you can double click it again.

Doing it on click is a little harder, you can use SelectionChange for that, but that will only work if the cursor was not previously in C9. Otherwise, you can make a link or button in C9 and use that, but this is the most basic solution.
 
  • #3
Neat! Gracias.
 

1. How do I increase a cell value by clicking on it in Excel?

To increase a cell value in Excel by clicking on it, you can use the "Increase Decimal" button in the Home tab or use the shortcut key "Ctrl + Shift + +" to add 1 to the cell value. You can also use the "Format Cells" option to specify a custom value to be added upon clicking the cell.

2. Can I set a specific value to be added upon clicking a cell in Excel?

Yes, you can set a specific value to be added upon clicking a cell in Excel by using the "Format Cells" option. In the "Number" tab, select "Custom" and specify the desired value in the "Type" field. This value will be added to the cell upon clicking it.

3. Is it possible to increase a cell value by more than 1 with a mouse click in Excel?

Yes, it is possible to increase a cell value by more than 1 with a mouse click in Excel. You can either use the "Increase Decimal" button multiple times or specify a larger value in the "Format Cells" option to be added upon clicking the cell.

4. How can I undo the increase of a cell value by a mouse click in Excel?

To undo the increase of a cell value by a mouse click in Excel, you can use the "Undo" button in the Quick Access Toolbar or use the shortcut key "Ctrl + Z". This will revert the cell value back to its previous state before the click.

5. Is there a way to automatically increase a cell value by clicking on it in Excel?

Yes, there is a way to automatically increase a cell value by clicking on it in Excel. You can use the "Data Validation" feature to create a list of values and select the option "Incremental Increase" in the "Settings" tab. This will automatically increase the cell value by the specified increment upon clicking it.

Similar threads

Replies
10
Views
3K
  • High Energy, Nuclear, Particle Physics
Replies
6
Views
739
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
10K
Replies
10
Views
2K
  • Astronomy and Astrophysics
Replies
2
Views
2K
  • Programming and Computer Science
Replies
2
Views
4K
  • STEM Academic Advising
Replies
6
Views
1K
Replies
15
Views
2K
Replies
6
Views
918
Back
Top