Order Numbers?

Youandih

New Member
Joined
Oct 8, 2013
Messages
7
Good day,

I have a question: I work at a phone retail shop, and we use Excel to make the receipts for our customers.
In order to find the receipts back if there's a problem, we have to (manually!) increase a number, the order number, everytime we open the file.

So, one customer comes, buys something, we make receipt and change the order number to e.g. 000501. We save it, we print it.
Then, the next customer comes, buys something, we make receipt and change order number to 000502, save, print.

Is there a way to automate that process, so that everytime we open the blank receipt, we get a sequential, unique number?

Thanks, Youandi Hoefman
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Are multiple people using the spreadsheet at once or are you just using it 1 person at a time? If it is only one at a time you could create a macro to clear all the cells and increase the order number by 1 after the file is saved so it is ready for the next use. Are you familiar with VBA at all?
 
Upvote 0
Are multiple people using the spreadsheet at once or are you just using it 1 person at a time? If it is only one at a time you could create a macro to clear all the cells and increase the order number by 1 after the file is saved so it is ready for the next use. Are you familiar with VBA at all?
Thanks for the response, only one person is using the receipt at a time. I am not familiar with VBA, but I know some scripting. Could you be as kind as to tell me where to start?
The order of actions must be (after filling in the cells) to save the filled receipt as e.g. "000501" (the order number) at a specific destination, then print that filled receipt, clear the cells, increase the number, and then save the empty increased number receipt as the original empty sheet which I opened before filling it in, so that next time, the number is increased.

<edit:>(EDIT: I just realized I actually am familiar with VBA, not much but I know the basics.)</edit:>
 
Last edited:
Upvote 0
Did you look at the link I posted?

Yes I've been doing that just now! Happy to say it worked!
Thank you for your cooperation :D

Just one question: is there a way to automatically save the file in a folder named "receipts\*.xls" with the "*" being the number used as the order number?

So when you filled in the receipt, and print it, it automatically calls it "1000502", and next time "1000503"?
 
Upvote 0
Code:
thisworkbook.saveas("C:\Path\To\Folder\Reciepts" & range("A1") & ".xls")

That is the line of code that would save it. Change the cell reference as necessary.
 
Upvote 0
Code:
thisworkbook.saveas("C:\Path\To\Folder\Reciepts" & range("A1") & ".xls")

That is the line of code that would save it. Change the cell reference as necessary.

Is there a way to build in a function that only when I print it, it saves it using the line you mentioned?
Preferably in a separate function.
 
Upvote 0
Add this to the ThisWorkbook Module.

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
ThisWorkbook.SaveAs ("C:\Path\To\Folder\Reciepts" & Range("A1") & ".xls")
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,840
Members
449,096
Latest member
Erald

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