+ Reply to Thread
Results 1 to 9 of 9

Macro to Create a New File and Save as Option

  1. #1
    Registered User
    Join Date
    10-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    82

    Macro to Create a New File and Save as Option

    Hi everyone,
    I would like to ask for help on some macro scripting.
    On my dummy sheet I have some data and a save button.
    What i would like to do is when i clicked the save button,
    Only the data (A5 to F20) will be copied on a different excel file and I will be prompted to save it as
    A new Excel file. Can this be done?

    Hope the scripting gurus will be able to help me again. Thank you in advance guys
    Attached Files Attached Files
    Last edited by Vincent.Eymard; 12-06-2010 at 09:40 AM.

  2. #2
    Forum Contributor
    Join Date
    11-25-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    120

    Re: Macro to Create a New File and Save as Option

    This can be done but you would have to specify if the range is always going to be the same? Otherwise you could copy the entire sheet and paste it in a new workbook.

    I'm going to assume it will alway be A5:F20
    If the post was helpful please click the black star on the bottom left to add some reputation and mark your thread as SOLVED.

    A day with nothing new achieved or learned, albeit however small, is a day lost forever?

    Constant Never Ending Improvement

  3. #3
    Registered User
    Join Date
    10-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: Macro to Create a New File and Save as Option

    Hi Lifesigns,
    Yes, the range will always be the same.
    I only changed the data on this dummy excel worksheet but basically the structure of my actual file is the same.
    Only columns A5 to F20.

    Thank you very much.

  4. #4
    Forum Contributor
    Join Date
    11-25-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    120

    Re: Macro to Create a New File and Save as Option

    Hi,

    I've attached a way of doing this provided the range is always going to be the same. When you click the command button it will ask for the file name and then save it to the folder path of the current file. This is the code I used:

    Please Login or Register  to view this content.
    I created a named range in the source workbook called CopyRng and as it was only values used an array to copy it to the new workbook.

    Hope that helps.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: Macro to Create a New File and Save as Option

    I think this just did it! You're a genius!
    Thank you so much!

  6. #6
    Registered User
    Join Date
    10-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: Macro to Create a New File and Save as Option

    By the way, Any idea how i could get to copy the field formatting aswell? Thanks.

  7. #7
    Registered User
    Join Date
    10-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: Macro to Create a New File and Save as Option

    Any suggestions how to do this? Thanks.

  8. #8
    Forum Contributor
    Join Date
    11-25-2010
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    120

    Smile Re: Macro to Create a New File and Save as Option

    Hi,

    If you want formatting as well you would have to change the code I used. If you press ALT+F8 it brings up the macro run dialog. There should only be one called SaveAS, if click on it so it is highlighted then from the buttons on the right select Edit. This will take you to the VBE and to the correct module. All you have to do now is change all the code with this code below:

    Please Login or Register  to view this content.
    This physically copies the range to the new workbook so any formatting or formulas will also be copied.

  9. #9
    Registered User
    Join Date
    10-13-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: Macro to Create a New File and Save as Option

    Perferct! Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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