• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Save invoice open new invoice

Norman_Atkinson

New Member
I have been following a number of tutorials on
creating an invoice,
saving the invoice as pdf,
clearing data from last invoice
opening a new invoice
having the invoice number automatically increase by one.

I have an error in the red row.

I do not know VB so am unable to correct the error. Help would be appreciated.

Thanks
Norman

>>> use code - tags <<<
Code:
Sub NextInvoice()
Range("H6").Value = Range("H6").Value + 1
Range("B17:E36").ClearContents

End Sub

Sub SaveInvWithNewName()
Dim NewFN As Variant
' Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "C:\David\Inv" & Range("E5").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:"xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice

End Sub
 
Last edited by a moderator:
hi @Norman_Atkinson ,

Test this but not sure

NewFN = "C:\David\Inv" & Range("E5").Value & ".xlsx"

Changed : NewFN = "C:\David\Inv" & Range("E5").Value

ActiveWorkbook.SaveAs NewFN, FileFormat:"xlOpenXMLWorkbook

Changed to :
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
 
Your changes have fixed the problem and I can now clear the old invoice and start a new one with the next invoice number.
My sincere thanks for your help.
 
Back
Top