+ Reply to Thread
Results 1 to 12 of 12

Combine workbooks

  1. #1
    Registered User
    Join Date
    05-08-2010
    Location
    Classified
    MS-Off Ver
    Excel 2003
    Posts
    7

    Combine workbooks

    Hi there everyone.

    Every day at the office, we need to combine several workbooks into one master workbook. I have a script that does this; however, I would like some modifications to it.

    For example, in a folder, I have three workbooks: Flowers.xls, Chocolates.xls, Stuffed Animals.xls. All three workbooks have two sheets each: Cost and Volume. The script creates a new workbook which has six sheets: Flowers, Flowers (1), Chocolates, Chocolates (1), Stuffed Animals, Stuffed Animals (1).

    I would like the script to automatically rename the tabs in the new workbook into: Flowers Cost, Flowers Volume, Chocolates Cost, Chocolates Volume, Stuffed Animals Cost, Stuffed Animals Volume.

    Any help with this would be greatly appreciated. Attached is the original script for your reference.

    :-)
    Attached Files Attached Files

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Combine workbooks

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    05-08-2010
    Location
    Classified
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Combine workbooks

    Okay, attached are several dummy workbooks (Flowers.xls, Chocolates.xls, and Stuffed Animals.xls) and the finished product of the script I am using (Combined Workbook.xls).

    Thank you for your help.

    :-)
    Attached Files Attached Files

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Combine workbooks

    Is this right?
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-08-2010
    Location
    Classified
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Combine workbooks

    Wow, it works perfectly. You are incredible. Thank you so so much. I am reviewing the script now.

    Is there any way I can pay you back? Barring actual currency and/or sexual favors.

    :-)

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Combine workbooks

    A variation, just 'cuz it's a quiet Saturday:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Combine workbooks

    hi Shg

    Can you please explain why this line works (implicit conversion etc?)?
    Please Login or Register  to view this content.
    I thought it would need to be similar to the below variations, but testing proves me wrong.
    Please Login or Register  to view this content.
    tia
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Combine workbooks

    CountA returns a (non-negative) number, and any number other than 0 is true.

    Buried in the bowels of the assembler is some statement like "branch non-zero somelinenumber." There's no need to compare a number to zero to return true/false, then branch on that result, rather than just using the number directly. It's not a conversion, it avoids one.

  9. #9
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Combine workbooks

    hi Shg,

    Ahhh, Thanks, there's always more to learn

    As you say, it's a quiet Saturday - where's everyone hiding, have they all gone to M$'s new Answers?

    Rob

  10. #10
    Registered User
    Join Date
    05-08-2010
    Location
    Classified
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Combine workbooks

    Hi again, and thanks for all the help so far.

    My problem now is: what if I want to combine selected sheets? The dummy workbooks I attached have only two sheets each: Cost and Volume. What if they had three sheets (Cost, Volume, and Date) and I only want two specific sheets (Cost and Volume) in my combined workbook? Is there a way to modify the script so that this is possible?

    :-)

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Combine workbooks

    I think the way to go would be a userform to list the sheets for each workbook then select from them.I'll have a play as soon as I get chance

  12. #12
    Registered User
    Join Date
    05-08-2010
    Location
    Classified
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Combine workbooks

    I have the issue temporarily solved with a hotkey (LOL) that unprotects the workbook and deletes the offending (!) sheet.

    Any further assistance would still be appreciated.

    :-)

+ 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