saving next invoice with the customer name and invoice number

sebo

New Member
Joined
Aug 22, 2020
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
after watching podcast 1505 and setting up an invoice that advances to the next invoice number, I figured out how to save it as a pdf. Now I'd like to save the invoice with the customer name as well as the invoice number. below is the code I've come up with so far.

Sub nextinvoice()
Range("l3").Value = Range("l3").Value + 1
Range("b15:b31,c15:e30,e10:j11,g15:g30,i15:i30,e8:j8,e12:j13,k15:k30,l31:l33,b35:e37").ClearContents
Sheets("customers").Range("o2").ClearContents
Sheets("cash").Range("e5:j5").ClearContents
End Sub

Sub SaveInvWithNewName()
Dim NewFN As Variant
' Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "c:\invoices\" & Range("l3").Value & ".xlsx"
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:="c:\pdf files\" & Range("l3").Value & ".pdf"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
nextinvoice
ActiveWorkbook.Save

End Sub
Thanks in advance
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
my invoice cell is l3 and my customer name cell is Sheets("customers").Range("o2") , how would this fit in the line you posted
Again many thanks
 
Upvote 0

Forum statistics

Threads
1,215,042
Messages
6,122,810
Members
449,095
Latest member
m_smith_solihull

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