Incrementing a cell on opening a workbook!

Steve_B

Board Regular
Joined
Feb 9, 2004
Messages
86
Hi All

I am sure that this question has been answered before and I would be grateful if someone could point me in the right direction.

I want to have a workbook that will increment a value in say A1 by 1 each time it opens, this value needs to be recorded even if the workbook is saved under another name.

First time A1 = 1
Second time A1 = 2
Etc, etc
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
tmischler said:
Hi Smitty - I didn't want to specify any sheet names either since I figured that if people might change the name of the workbook, they might change the name of the tab as well - not that that makes my code free from problems either...

Instead of the sheet name, use the sheet's CodeName, or its Index number.
 
Upvote 0
:oops: I should have checked where I put the code!

Both options work great

I would like to know if this increment in the cell can now be saved or remembered even if I don't save the workbook?
 
Upvote 0
Not in the way we've been going.

You'd have to increment a value in ANOTHER file and save that file, in your on-open macro, to do that I think.
 
Upvote 0
that's kind of what I was wondering too - so there's no other way of declaring a variable that makes it last longer than static?
 
Upvote 0
Well, no.

BUT -- in your on-open, why not 1] increment the cell, then 2] do an immediate save of the file?
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,510
Members
448,967
Latest member
screechyboy79

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