Auto number

niecie

New Member
Joined
Jan 20, 2005
Messages
5
I am creating a transmittal form for a client. One of the features they would like in the form is to have the form change in increments of 1 everytime the form is opened. For example, the form is like an invoice. So they want the cell in which the "invoice number" resides to change everytime the form is opened. Can you help?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,105
Office Version
  1. 365
How about storing the value in some hidden, unused cell?

Then, code similar to this msgbox example might work:

Sub box()
Sheets("sheet1").Range("z1") = Sheets("sheet1").Range("z1").Value + 1
MsgBox "This is number "&Sheets("sheet1").Range("z1").Value , vbOKOnly, "Invoice #" & Sheets("sheet1").Range("z1")
End Sub
 

JPM

Active Member
Joined
Aug 1, 2002
Messages
407
What you can do is to add the following code to the sheet (not a module)
Code:
Private Sub Worksheet_Activate()
Invoice = Range("I3").Value + 1 'if the invoice number is in cell I3
Range("I3").Formula = Invoice
End Sub
The only problem with this is that it will update the number everytime it is activated. So if you want to look at the same invoice again in a few days, it will update itself again.

JPM
 

JPM

Active Member
Joined
Aug 1, 2002
Messages
407
You could however disable the macro when you reopen the file, which then would not change the number.

JPM
 

Forum statistics

Threads
1,181,821
Messages
5,932,258
Members
436,830
Latest member
Sochen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top