Auto Update Number on opening or closing

C0^sTy

New Member
Joined
Oct 26, 2006
Messages
3
Hi Guys,

I was hoping you might be able to help me with this. I have got a purchase order form on Excel. Is it possible to have the actual purchase order number update itself upon opening or maybe even closing? Like it starts at say 1001, then the next time I open it it will have changed to 1002, then the next time 1003 etc etc ...

Reason for wanting to do this is so everytime the form is filled out and printed it would have a different purchase order number. Do you guys know if this possible?

Thanks! :biggrin:
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Hi
try
Code:
Private Sub Workbook_Open()

With Sheets("Sheet1").Range("a1") ' <- change to suite
   .Value = WorksheetFunction.Max(1001, .Value + 1)
End With

End Sub
 

C0^sTy

New Member
Joined
Oct 26, 2006
Messages
3
Hey jindon!

That seems to work when I run the macro but can I get it to run on its own like when I open the Excel sheet or maybe just when it closes? Like it opens on 1001 and I fill in the details then print, then the next time it opens it would be on 1002?
 

Watch MrExcel Video

Forum statistics

Threads
1,108,786
Messages
5,524,865
Members
409,606
Latest member
TRINBB

This Week's Hot Topics

Top