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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
 
Upvote 0
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
 
Upvote 0
You could however disable the macro when you reopen the file, which then would not change the number.

JPM
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,448
Members
448,966
Latest member
DannyC96

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
Back
Top