Macro to count up by 1 each time used

decliam25

New Member
Joined
Feb 8, 2023
Messages
2
Office Version
  1. 365
Platform
  1. MacOS
Hi all,

This is my first time posting to this forum. I am very new to macros and have no idea what I am doing. I want to use a macro to count up by 1 each time the macro is used, so the value outputted value to the cell will be 1,2,3,4,5,6 etc.

Any help would be greatly appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Welcome to the Board!

You can put something like this at the bottom of your current code:
VBA Code:
'   Increment counter in cell A1
    Range("A1").Value = Range("A1").Value + 1
'   Save workbook
    ActiveWorkbook.Save
You will just want to be sure that the workbook is Saved, as if they close it without saving, you will "lose" that incremented value and it will revert back to the previous value.
 
Upvote 1

Forum statistics

Threads
1,215,338
Messages
6,124,356
Members
449,155
Latest member
ravioli44

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