+ Reply to Thread
Results 1 to 8 of 8

Save file based on cell value on a specific sheet

  1. #1
    Registered User
    Join Date
    05-15-2017
    Location
    Hampshire
    MS-Off Ver
    2010
    Posts
    5

    Save file based on cell value on a specific sheet

    Hi,

    I have the below code to save the file in a specific location based on a cell name. The cell name is concatenated based on today's date, the files name, this month and then the time created.

    However, whenever I run the macro to save, the below section comes up as an run time error 1004.

    Please Login or Register  to view this content.
    The naming convention of the file will be the below once concatenated. The cell is still a formula once the save as code is run.

    2017-05-30 Issue Tracker May 11:14:23
    Does anyone know how to resolve the error please or any other code to help make it run smoother.

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Save file based on cell value on a specific sheet

    FPpath's last character is \
    But you are combining ANOTHER \ in the "ThisWorkBook" variable so you're ending up with

    \\Homeshare\HOME0027\G019\My Documents\\ & FName

    The first \\ is fine if you are saving the file to a server but the second pair doesn't look at all right to me.

    Change this:

    Please Login or Register  to view this content.
    to this

    Please Login or Register  to view this content.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    05-15-2017
    Location
    Hampshire
    MS-Off Ver
    2010
    Posts
    5

    Re: Save file based on cell value on a specific sheet

    Hi,

    Thanks for this. However, still get the "Run-time error '1004': Method 'SaveAs' of object'_Workbook' failed, on the same section

    Am I still doing something wrong.

    Thanks

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Save file based on cell value on a specific sheet

    I would also add:

    Please Login or Register  to view this content.
    Or which ever extension you intend.

  5. #5
    Registered User
    Join Date
    05-15-2017
    Location
    Hampshire
    MS-Off Ver
    2010
    Posts
    5

    Re: Save file based on cell value on a specific sheet

    Hi

    Sorry this unfortunately also does not work. It has only stopped working today, since I added the time to the end of the concatenate formula.

    Thanks

  6. #6
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Save file based on cell value on a specific sheet

    1. Change the name of the sub to something else, SaveAs is probably a reserved word.

    2. Change your pathname to something local like C:\
    Run the program again.
    If it works and saves to the C drive then you dont have access to the server youre trying to save to.

  7. #7
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Save file based on cell value on a specific sheet

    Times as text will include colons.
    You can't have colons as part of a filename.
    Replace them with hyphens or omit them altogether.

  8. #8
    Registered User
    Join Date
    05-15-2017
    Location
    Hampshire
    MS-Off Ver
    2010
    Posts
    5

    Re: Save file based on cell value on a specific sheet

    Hi

    Thanks that was the reason. Now all resolver. Thanks again for your help

+ 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. Save sheet as pdf with cell-based filename in a specific filepath
    By CoachK88 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-16-2017, 05:43 PM
  2. [SOLVED] Save Each Worksheet as a PDF File and Name each File Based on a Cell Value in each Sheet
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2016, 09:36 AM
  3. [SOLVED] Save sheet as PDF with specific file path
    By KEDENNIS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2016, 07:32 PM
  4. [SOLVED] macro to save sheet with specific file name from sheet
    By mezza89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2013, 12:04 PM
  5. Replies: 0
    Last Post: 07-11-2013, 02:08 AM
  6. Save specific sheet to location based on contents of cell
    By KJL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2012, 08:08 AM

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