Results 1 to 2 of 2

Thread: Generate Invoice Number Based on date

  1. #1
    Neophyte jongnj87's Avatar
    Join Date
    Apr 2021
    Posts
    1
    Articles
    0
    Excel Version
    Microsoft Officer 2019

    Generate Invoice Number Based on date



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    Administrator AliGW's Avatar
    Join Date
    Nov 2015
    Location
    Ipswich, Suffolk, England
    Posts
    1,660
    Articles
    0
    Excel Version
    Office 365 Subscription
    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-pro...d-on-date.html

    Also, in future, please use code tags around your code. I'll do that for you as well.
    Ali
    Enthusiastic self-taught user of MS Excel!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •