Sub InvoiceReport() Dim myFile As String, lastRow As Long myFile = "C:\Users\iaquino\Documents\Invoices\" & _ Sheets("Invoice").Range("A10") & "_" & _ Sheets("Invoice").Range("F4") & _ Format(Now(), "yyy-mm-dd") & ".pdf" lastRow = Sheets("Invoice File").UsedRange.SpecialCells(xlCellTypeLastCell).Row + 1 'Transfer data to Invoice File Sheets("Invoice File").Cells(lastRow, 1) = Sheets("Invoice").Range("A10") Sheets("Invoice File").Cells(lastRow, 2) = Sheets("Invoice").Range("F4") Sheets("Invoice File").Cells(lastRow, 3) = Sheets("Invoice").Range("F28") Sheets("Invoice File").Cells(lastRow, 4) = Now Sheets("Invoice File").Hyperlinks.Add Anchor:=Sheets("Invoice File").Cells(lastRow, 5), Address:=myFile, TextToDisplay:=myFile 'Create invoice in PDF format Sheets("Invoice").ExportAsFixedFormat Type:=xlTypePDF, Filename:=myFile Application.DisplayAlerts = False 'create invoice in XLSX format ActiveWorkbook.SaveAs "C:\Users\iaquino\Documents\invoices\" & _ Sheets("Sheet1").Range("A10") & "_" & _ Sheets("Invoice").Range("F4") & "_" & _ Format(Now(), "yyy-mm-dd") & "xlsx", FileFormat:=51 Application.DisplayAlerts = True End Sub
myFile
lastRow = Sheets("Invoice File").UsedRange.SpecialCells(xlCellTypeLastCell).Row + 1
lastRow = Sheets("Invoice File").UsedRange.RowS.Count + 1
ExportAsFixedFormat
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)