Generate Invoice Number Based on date

jongnj87

New member
Joined
Apr 7, 2021
Messages
1
Reaction score
0
Points
0
Excel Version(s)
Microsoft Officer 2019
Good Day All,
I am just curious whether am I able to auto generate invoice number based on actual date.
E.g. Today is 7 Apr 2021 and my Invoice number usually will be 202104070001(DDMMYYY0001)
My invoice number will be at "C5"
So I change it manually. My VBA already auto +1 when I save the invoice and is will save as the customer name "C9"
Anyone able to guide me on this please.
Thank You.
Below are my code for my invoice


Code:
Private Sub CommandButton1_Click() 
'for Final Words Strikethrough Range("D47").Font.Color = vbRed Range("D47").Font.Strikethrough = True  

'for PDF Draft file save Sheet9.Range("A1:I51").ExportAsFixedFormat xlTypePDF, Filename:= _ "C:\Users\JOYCELYN SEE\Desktop\FENG YUN\RECEIPT\Draft PDF" & Sheet9.Range("C9").Value, OpenAfterPublish:=True  

'for Final Word UnStrikethrough 
Range("D47").Font.Color = vbBlack 
Range("D47").Font.Strikethrough = False  

'for xl file save ActiveSheet.Copy With ActiveWorkbook .SaveAs "C:\Users\JOYCELYN SEE\Desktop\FENG YUN\RECEIPT\Draft Receipt" & Sheet9.Range("C9").Value, FileFormat:=xlOpenXMLWorkbookMacroEnabled  

'for Receipt number Sheet9.Range("C5").Value = Sheet9.Range("C5").Value + 1  

'for clear receipt 
Sheet9.Range("C9:I13").ClearContents 
Sheet9.Range("B16:B35").ClearContents 
Sheet9.Range("F16:F35").ClearContents 
Sheet9.Range("G16:G35").ClearContents 
End With  

End Sub  

Private Sub CommandButton3_Click() 
'for Draft Word Strikethrough 
Range("C47").Font.Color = vbRed 
Range("C47").Font.Strikethrough = True  

'for Final Word UnStrikethrough 
Range("D47").Font.Color = vbBlack 
Range("D47").Font.Strikethrough = False  

'for PDF Final file save Sheet9.Range("A1:I51").ExportAsFixedFormat xlTypePDF, Filename:= _ "C:\Users\JOYCELYN SEE\Desktop\FENG YUN\RECEIPT\Fianl Receipt" & Sheet9.Range("C9").Value, OpenAfterPublish:=True  

'for Draft Word UnStrikethrough 
Range("C47").Font.Color = vbBlack 
Range("C47").Font.Strikethrough = False  

End Sub
 
Administrative Note:

It has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

Read this to understand why we (and other sites like us) consider this to be important.

Here is the link: https://www.excelforum.com/excel-pr...04-generate-invoice-number-based-on-date.html

Also, in future, please use code tags around your code. I'll do that for you as well.
 
Back
Top