Urgent help please, Save a selection of cells in Excel and save to PDF.
I have an excel file in which I have a VBA to "Save Invoice Both Ways and Clear" The macro I have saves the whole worksheet as "xlsx and a PDF" file.
I really need this macro to save only the selected cell range "A1:N116" within this worksheet, and save both ways. I'm not very good at Macro's and needed help to get my existing macro working. It works perfectly now. Any help adjusting my existing macro to copy a range of cells instead of the whole "active Sheet" would be of so much help.
Here is my existing macro....
Sub SaveRangeBothWaysAndClear()
Dim NewFN As Variant
NewFN = "\\Z:\Company files\PDF Invoice copies\Doc" & Range("N5").Value & "" & Range("N10").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
ActiveSheet.Copy
NewFN = "\\Z:\Company files\Excel Invoice Copies 2022\Inv" & Range("N5").Value & "" & Range("N10").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
Range("N5").Value = Range("N5").Value + 1
Range("B10:K10,A11:K14,A15:C15,F15:K15,N4,N10:N15,A17:N19,C22:N23,C25:M30,C34:M37,C40:M45,A73:N76,A79:M100").ClearContents
End Sub
Thanks to anyone who can help
I have an excel file in which I have a VBA to "Save Invoice Both Ways and Clear" The macro I have saves the whole worksheet as "xlsx and a PDF" file.
I really need this macro to save only the selected cell range "A1:N116" within this worksheet, and save both ways. I'm not very good at Macro's and needed help to get my existing macro working. It works perfectly now. Any help adjusting my existing macro to copy a range of cells instead of the whole "active Sheet" would be of so much help.
Here is my existing macro....
Sub SaveRangeBothWaysAndClear()
Dim NewFN As Variant
NewFN = "\\Z:\Company files\PDF Invoice copies\Doc" & Range("N5").Value & "" & Range("N10").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
ActiveSheet.Copy
NewFN = "\\Z:\Company files\Excel Invoice Copies 2022\Inv" & Range("N5").Value & "" & Range("N10").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
Range("N5").Value = Range("N5").Value + 1
Range("B10:K10,A11:K14,A15:C15,F15:K15,N4,N10:N15,A17:N19,C22:N23,C25:M30,C34:M37,C40:M45,A73:N76,A79:M100").ClearContents
End Sub
Thanks to anyone who can help