mohammed_chand
New Member
- Joined
- Oct 30, 2020
- Messages
- 7
- Office Version
- 365
- Platform
- Windows
i have following code in my Module.
currently code saves invoices with invoice number. however i would like to add customer name with invoice number.
Invoice number is in D5 and customer name is in B11.
i would appreciate your help on this. how do i tweak my code to get customer name with invoice number.
Sub SaveInvoiceBothWaysAndClear()
Dim NewFN As Variant
' Create the PDF First
NewFN = "C:\Users\User\Desktop\invoice\" & Range("D5").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
' Next, Save the Excel File
ActiveSheet.Copy
NewFN = "C:\Users\User\Desktop\invoice\" & Range("D5").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
Range("D5").Value = Range("D5").Value + 1
Range("A14:C23").ClearContents
Range("B11").ClearContents
Range("A11").ClearContents
ActiveWorkbook.Close SaveChanges:=True
End Sub
currently code saves invoices with invoice number. however i would like to add customer name with invoice number.
Invoice number is in D5 and customer name is in B11.
i would appreciate your help on this. how do i tweak my code to get customer name with invoice number.
Sub SaveInvoiceBothWaysAndClear()
Dim NewFN As Variant
' Create the PDF First
NewFN = "C:\Users\User\Desktop\invoice\" & Range("D5").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
' Next, Save the Excel File
ActiveSheet.Copy
NewFN = "C:\Users\User\Desktop\invoice\" & Range("D5").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
Range("D5").Value = Range("D5").Value + 1
Range("A14:C23").ClearContents
Range("B11").ClearContents
Range("A11").ClearContents
ActiveWorkbook.Close SaveChanges:=True
End Sub