Excel to automatically add to one cell

posfog

Board Regular
Joined
Jun 2, 2009
Messages
171
Hi All,
I just wondered if someone could advise on how the follow.

I need to be able off the back of a macro for one cell to keep a count of every time a button is pressed.

I google sheets i know this is possible with the following function as show below, but wondered if the same could be done in excel?

function b4plus() {
ss=SpreadsheetApp.getActiveSpreadsheet()
s=ss.getActiveSheet()
var currVal=s.getRange("B9").getValue()
var plusVal= currVal +1
s.getRange("B9") .setValue(plusVal)
}

Kind Regards
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Use this and simply assign it to your button

Code:
Sub MM1()
Sheet1.[B9] = Sheet1.[B9].Value + 1
End Sub
 
Upvote 0
Thanks for that

Am i correct in thinking if i wanted it to remove (minus 1) i do the following?

Sub MM1()
Sheet1.[B9] = Sheet1.[B9].Value - 1
End Sub
 
Upvote 0
yep...easiest way, give it a try and see what happens !!!
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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