Number Sequence for New/Next Spreadsheet

battison

New Member
Joined
Nov 28, 2005
Messages
4
I have an order form with a "customer number" that is different with each order. I manually type in the number. But I would like to have the number automatically change/increase by 1 increment when I open and save the next new customer form. Is this possible?
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Yes, it is. You could put something like this into your ThisWorkbook module ...


<font face=Tahoma New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_BeforeSave(<SPAN style="color:#00007F">ByVal</SPAN> SaveAsUI <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN>, Cancel As <SPAN style="color:#00007F">Boolean</SPAN>)
    <SPAN style="color:#00007F">With</SPAN> Sheets("Sheet1").Range("A1")
        .Value = .Value + 1
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Open()
    <SPAN style="color:#00007F">With</SPAN> Sheets("Sheet1").Range("A1")
        .Value = .Value + 1
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>


HTH
 

Watch MrExcel Video

Forum statistics

Threads
1,118,530
Messages
5,572,706
Members
412,481
Latest member
nhantam
Top