mrgunn's Avatar
mrgunn 4
5 Asked
226 Answered
39 Best
0
No one has voted on this question yet :(
3 years, 5 months ago

How do I make Excel 2007 increment the value in a given cell whenever the file is opened?

I'd like to give a series of worksheets I'm generating a serial number, and since each successive worksheet is derived by modifying the previous one, it seems like a formula to increment a cell upon file open would easily achieve this. Alternatively, I could write to a separate file upon file close, then read from that separate file upon opening the next file, and add 1.
Tip for best answer: M$0.00
Separate topics with commas, or by pressing return. Use the delete or backspace key to edit or remove existing topics.

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$

What is Your Answer?

0
0
0

1 Answer

1
sanguivore's Avatar
sanguivore | 3 years, 5 months ago
0
Hit Alt-F11 to go to Visual Basic. Double-click on This Workbook, and in the code field, paste:

Private Sub Workbook_Open()
Range("A1").Value = Range("A1").Value + 1
End Sub

You can modify the cell to whatever you need of course. Note you have to have macros enabled or at least set it to prompt for macros in the Security settings. This will increment the cell's value by 1 whenever you open the workbook. In Excel 2007, you will have to save the workbook as .xlsm or as a .xls (97-2003 format).

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$
mrgunn's Avatar
mrgunn | 3 years, 5 months ago Report

I figured there would be some VB involved. Cheers, mate!

mrgunn's Avatar
mrgunn | 3 years, 4 months ago Report

You know, this actually doesn't work, even with macros enabled. I'll have to send someone the form I'm using and see if they can get it working.

sanguivore's Avatar
sanguivore | 3 years, 4 months ago Report

I tested it to verify, and it was working. You have to save it to actually have it increment of course, otherwise the value reverts.

Report Abuse

Post Reply Cancel

Learn something new with our FREE educational apps!

Private lessons in the comfort of your own home. Get back in shape or finally pick up a guitar with our great experts guiding you the whole way!
Learn Guitar
Learn Hip Hop
Learn Pilates