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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,214,988
Messages
6,122,620
Members
449,092
Latest member
amyap

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