Results 1 to 4 of 4

Thread: Save Macro

  1. #1

    Save Macro



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    Acolyte patel's Avatar
    Join Date
    Feb 2014
    Location
    Italy
    Posts
    59
    Articles
    0
    Code:
    Sub savecopy()
        fpath = ThisWorkbook.Path & "\"
        CurrentInvoiceNum = Range("M9")
        Fname = fpath & Replace(CurrentInvoiceNum, "\", "_") & ".xlsm"
        ActiveWorkbook.SaveCopyAs Filename:=Fname
    End Sub

  3. #3
    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?

  4. #4
    Acolyte patel's Avatar
    Join Date
    Feb 2014
    Location
    Italy
    Posts
    59
    Articles
    0
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •