I'm new to VBA coding and have an issue with my SaveInvWithNewName code. My workbook contains one open worksheet (Invoice) and four hidden worksheets (Service Date, Work Order, Purchase Order, & Employee). The hidden worksheets need to remain hidden. The open worksheet pulls data from the four hidden worksheets.
I've added a shape and assigned macro to the open worksheet. When I click the shape to perform “Save & Next Invoice Number” function, it goes to the next invoice number and only saves the open worksheet; it does not save the hidden worksheets. Is there a code that can perform a “Save Entire Workbook & Next Invoice Number”?
VBA code:
Sub SaveInvWithNewName()
Dim NewFN As Variant
' Copy Invoice to a new workbook
ActiveWindow.SelectedSheets.Copy
NewFN = "C:\ABC\Invoices\" & Range("D7").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
End Sub
I've added a shape and assigned macro to the open worksheet. When I click the shape to perform “Save & Next Invoice Number” function, it goes to the next invoice number and only saves the open worksheet; it does not save the hidden worksheets. Is there a code that can perform a “Save Entire Workbook & Next Invoice Number”?
VBA code:
Sub SaveInvWithNewName()
Dim NewFN As Variant
' Copy Invoice to a new workbook
ActiveWindow.SelectedSheets.Copy
NewFN = "C:\ABC\Invoices\" & Range("D7").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
End Sub