+ Reply to Thread
Results 1 to 4 of 4

VBA code to save as file with specific file name

Hybrid View

  1. #1
    Registered User
    Join Date
    10-24-2011
    Location
    Orlando, FL
    MS-Off Ver
    Office 365 for Business
    Posts
    89

    VBA code to save as file with specific file name

    Looking for code to save a file as a specific file name. For example, want file name to always contain the work DECO, followed by a space, followed by a job number.
    Such as:
    DECO 291131.xlsm

    The job number is found in cell L5 in worksheet LOAD LIST. I have multiple worksheets.

    Thank you!

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: VBA code to save as file with specific file name

    Hello there,

    Below is the code you would use. You would manually need to select the sheet and then run the macro below. Also, you will need to insert the beginning of your file path into where I have instructed below.

    Let me know if you have any questions! Thanks!

    Sub macro2()
    Dim wbNew As Workbook
    
    ActiveSheet.Select
    ActiveSheet.Copy
    
    Set wbNew = ActiveWorkbook
    With wbNew
        ActiveWorkbook.SaveAs Filename:= _
         "your file path goes here" & Range("G4").Value & ".xlsm" _
        , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
        .Close
    End With
    
    End Sub

  3. #3
    Registered User
    Join Date
    10-24-2011
    Location
    Orlando, FL
    MS-Off Ver
    Office 365 for Business
    Posts
    89

    Smile Re: VBA code to save as file with specific file name

    Wonderful! It worked. Thanks for the help!!

  4. #4
    Registered User
    Join Date
    07-14-2004
    Posts
    1

    Re: VBA code to save as file with specific file name

    Helpful to me too, thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1