Code:Sub savecopy() fpath = ThisWorkbook.Path & "\" CurrentInvoiceNum = Range("M9") Fname = fpath & Replace(CurrentInvoiceNum, "\", "_") & ".xlsm" ActiveWorkbook.SaveCopyAs Filename:=Fname End Sub
Hi
I'm looking for some help with a macro on an invoice I have. Currently I have a macro that auto increments the invoice number, and clears the contents of the document for ease of use. I would also like it to do 1 more thing, that is to save the invoice as a separate standard xls document, auto saving it as the invoice number, leaving the original document as a template so to speak. I've uploaded the document so you can see what is on it as present. The invoice number is in cell M9, and is structured like this 14/1234, with 14 being the year. Hope this makes sense.
Any help would be great, thanks, really struggling with this part.
blank invoice doc1.xlsm
Bangert
Code:Sub savecopy() fpath = ThisWorkbook.Path & "\" CurrentInvoiceNum = Range("M9") Fname = fpath & Replace(CurrentInvoiceNum, "\", "_") & ".xlsm" ActiveWorkbook.SaveCopyAs Filename:=Fname End Sub
Thanks Patel, much appreciated.
I've had an oversight though, forgot some things. Is it possible for the macro to save just the active sheet, as a standard xlsx file, and with the macro's stripped once saved. Should have thought of this before posting!!
Are these things possible?
Code:Sub savecopy2() fpath = ThisWorkbook.Path & "\" CurrentInvoiceNum = Range("M9") Fname = fpath & Replace(CurrentInvoiceNum, "\", "_") & ".xlsx" ActiveSheet.Copy ActiveWorkbook.SaveAs Filename:=Fname, FileFormat:= _ xlOpenXMLWorkbook, CreateBackup:=False ActiveWorkbook.Close End Sub
Last edited by patel; 2014-02-20 at 10:30 PM.
Bookmarks