automatic numbering of cells in excel

G

George

Is there a way to make a cell automatically number itself everytime the work
book is opened? I would like to create an invoice that automatically changes
it's number when opened.
 
G

Gary''s Student

To make cell A1 in Sheet1 increment every time the workbook is opened:

In ThisWorkbook code enter the following macro:

Private Sub Workbook_Open()
Set r = Sheets("Sheet1").Range("A1")
r.Value = r.Value + 1
End Sub
 
G

George

Thanks Gary, I am a little green with macros - can you explain this in
greater detail - please?
 
G

Gary''s Student

1. touch ALT-F11 to bring up VBA
2. right-click TisWorkbook in the left hand panel
select view code
3. paste the stuff in
4. close the VBA window (save is not necessary)
 
G

George

Thanks again Gary - that worked great, but do I have to leave the "Enable all
macros (not recommended...) checked for this to work?
 
G

Gary''s Student

If you are concerned:

1. leave the Security settings at a level you ae comfortable with
2. don't open this workbook with a double click to an icon, instead:
3. open Excel
4. fix the security setting to allow this macro
5. open the file
6. after closing the file restore the settings.
 
G

George

Thanks again Gary - now do you have any good connections for some help with
Infopath?
 
Top