+ Reply to Thread
Results 1 to 5 of 5

Macro to automatically save an Excel with a specific name depending on cell value

  1. #1
    Registered User
    Join Date
    07-04-2013
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2007
    Posts
    4

    Macro to automatically save an Excel with a specific name depending on cell value

    Hello,

    So far, I created a macro to save a Excel workbook with a specific name depending on the value entered in defined cells:

    ActiveWorkbook.SaveAs _
    Filename:=Application.GetSaveAsFilename(Range("B4") & " " & Range("B9") & " Form", _
    FileFilter:="Excel File(*.xls),"), _
    FileFormat:=xlNormal


    Until here the macro works fine and correct.

    However, I want to extend the macro that the file now gets automatically saved in a specific folder.

    The path of the folder is as follow:
    C:\Users\Stefan.Ahrendt\Desktop\DART\Client Approval\test.xls

    Whereby, "test.xls" is the name of the file that I want to replace by the macro stated above.

    Any advise how this can be done?

    Thanks,

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to automatically save an Excel with a specific name depending on cell value

    Hi, Stefan1979,

    please use code-tags when displaying code here on Excel Forum.

    Use ChDrive and ChDir to get to that directory prior to calling the routine or use InStrRev to get the part of th ename after the last / and add that to the desired path to save.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    07-04-2013
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Macro to automatically save an Excel with a specific name depending on cell value

    Hello Holgar,

    Thanks for your reply. Updating the code as suggested worked.

    One additional question: after running the updated macro, the "Save As" pop-up window still shows up where I have to hit the save button.

    Is there a way to modify the macro so that the file gets automatically saved by just running the macro.

    Thanks,

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Macro to automatically save an Excel with a specific name depending on cell value

    Hi, Stefan1979,

    could be done with a slight modification:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    07-04-2013
    Location
    Barcelona, Spain
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Macro to automatically save an Excel with a specific name depending on cell value

    Hello Holgar,

    Thanks for the feedback - works perfect now.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Rule to save attachments to specific folders depending on attachment file name
    By ndrobinson in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 09-17-2013, 04:16 PM
  2. Replies: 0
    Last Post: 07-11-2013, 02:08 AM
  3. Replies: 1
    Last Post: 06-30-2013, 05:58 PM
  4. Macro that is column specific & changes cell color depending on cell contents
    By zurispowell in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2012, 05:03 PM
  5. Replies: 3
    Last Post: 07-08-2010, 06:48 PM

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