Save Macro

bangert

New member
Joined
Feb 19, 2014
Messages
2
Reaction score
0
Points
0
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.

View attachment blank invoice doc1.xlsm

Bangert
 

patel

New member
Joined
Feb 20, 2014
Messages
60
Reaction score
0
Points
0
Location
Italy
Excel Version(s)
2010
Code:
Sub savecopy()
    fpath = ThisWorkbook.Path & "\"
    CurrentInvoiceNum = Range("M9")
    Fname = fpath & Replace(CurrentInvoiceNum, "\", "_") & ".xlsm"
    ActiveWorkbook.SaveCopyAs Filename:=Fname
End Sub
 

bangert

New member
Joined
Feb 19, 2014
Messages
2
Reaction score
0
Points
0
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?
 

patel

New member
Joined
Feb 20, 2014
Messages
60
Reaction score
0
Points
0
Location
Italy
Excel Version(s)
2010
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:
Top