Forum Home
Press F1
 
Thread ID: 62588 2005-10-12 19:41:00 Excel John_Robb (9061) Press F1
Post ID Timestamp Content User
395590 2005-10-12 19:41:00 Is it possible to have a cell in Excell that automatically increases a number by 1 each time the shhet is opened? I want an auto number in sequence in a form rather like an invoice number.
Any ideas would be appreciated
Thanks
John_Robb (9061)
395591 2005-10-12 19:59:00 I'm sure it can be done with a macro but I'm not that good at it to tell you how. I've gotten a lot of good answers to questions by asking these guys though. You can give it a shot. They answer pretty quickly.
www.allexperts.com
iguana (89)
395592 2005-10-13 00:06:00 The following macro code if placed into the VB editor of a worksheet will increase the value of the number in cell A1 by 1 everytime the worksheet is activated.
With the workbook open press <Alt F11> to bring up the VB editor.
Open the Microsoft Excel Objects folder then double click on the worksheet name required and paste the code into the pane which appears on the right hand side.
Edit Range("a1") to whatever cell contains your number to be increased.
Return to Excel via <Alt F11>.
If you want to increase the number every tme the workbook is opened, different code is required.

Private Sub Worksheet_Activate()
Range("A1").value = Range("A1").value + 1
End Sub
rad_s4 (7401)
395593 2005-10-13 06:12:00 If you replace Private Sub Worksheet_Activate() with Private Sub Workbook_Open() the macro should increment the value by 1 on opening. This works for Excel Office XP TeejayR (4271)
1