+ Reply to Thread
Results 1 to 8 of 8

macro for saving multiple worksheets in to a new workbook

  1. #1
    Registered User
    Join Date
    05-08-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    7

    macro for saving multiple worksheets in to a new workbook

    Hi, I cannot get the below to work correctly for me. I am trying to copy two worksheets form a certain workbook in to a new workwork. This new workbook is then saved down every day in the following location T:\InterDepartment\Pricing\Loans\. I want to create a saving code that updates the file in to a corresponding month folder and then eventually a year folder. I keep gettting an error message on the code below ( which is mostly copied an applied from other websites etc)
    Any help would be greatly appreciated
    Please Login or Register  to view this content.
    Last edited by arlu1201; 05-08-2012 at 06:13 AM. Reason: Please use code tags in future.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro for saving multiple worksheets in to a new workbook

    Should the contents of the sheets be copied to the destination workbook or should the sheets copied entirely (like using a move/copy)?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-08-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: macro for saving multiple worksheets in to a new workbook

    Quote Originally Posted by arlu1201 View Post
    Should the contents of the sheets be copied to the destination workbook or should the sheets copied entirely (like using a move/copy)?
    The contents of the sheets should be copied in full.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro for saving multiple worksheets in to a new workbook

    Can you give me some more details like -

    1.Name of the source file and path if the file needs to be opened by the macro.
    2. Name of the destination file and path if the file needs to be opened by the macro.
    3. Names of the sheets that need to be copied.
    4. Names of the month & year folders where the file should be saved.

  5. #5
    Registered User
    Join Date
    05-08-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: macro for saving multiple worksheets in to a new workbook

    1. The macro will run on the file I open daily. It will be a template as such which is updated and the final report which is saved only contains the two worksheets.
    2.No file needs to be opened to run the file.
    3.The sheets that need to be copied are Prices and Markit Compare.
    4. I want the completed file with the two sheets - Prices and markit Compare to be saved on the following loaction T:\InterDepartment\Pricing\Loans\2012\May 12, this month folder changing automatically in June and so on.

    Any thing else please ask... I hope that is clear now.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro for saving multiple worksheets in to a new workbook

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: macro for saving multiple worksheets in to a new workbook

    How about this:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  8. #8
    Registered User
    Join Date
    05-08-2012
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: macro for saving multiple worksheets in to a new workbook

    Thanks guys so so much problem is sorted and it is working fine. 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