+ Reply to Thread
Results 1 to 13 of 13

Add-in to saving groups of worksheets as a single workbook

  1. #1
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35

    Add-in to saving groups of worksheets as a single workbook

    Hi all

    I have another little conumdrum I'm trying to work out.

    I'm using one of Ron's scripts as an add-in which I've just amended the output path for.

    http://www.rondebruin.nl/tips.htm

    This script essentially creates a new workbook from each worksheet in the active workbook.

    As I have a workbook of about 500 worksheets, I am trying to group the worksheets opposed to having to split all and rejoin them manually.

    Luckily all of my worksheets names are initials with numbers after them (as assigned by excel when merged):

    e.g., RH, RH (2), RH (3), RH (4), AG, AG (2), AG (3) and so on.

    That said there are some random ones too, but I'm happy for them to be kicked out as individual files.

    Anyway I'm pretty sure there is a way this can be added into this existing script by addressing Sheet.Name perhaps but I'm a bit unsure exactly..

    Sorted in order (i.e. 2,3,4) would also be a bonus but not essential as they need to manually checked and I have a separate macro for sorting worksheets anyway.

    Any input would be much appreciated!!

    Cheers

    Danny

    Please Login or Register  to view this content.
    /
    ----
    OOO

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Do you have a list of initials stored in the workbook?
    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
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    No, unfortunately not. I'd have to use Sourcewb.Sheets.Name in this instance as there is no common cells across all sheets.

    I thought about using Case but the script would get too bulky.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I think you need a list of initials, maybe created with the code then loop through the list to create the workbook.

  5. #5
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    Yeah the initials could be created in the code. i'll try that first. cheers!

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

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    Hi Roy

    Thanks for your input so far.

    Sorry I forgot to mention... some worksheets have 3 characters, e.g. ABR and other just have 2 e.g. AG. The list generated therefore truncates some of these names. I tried changing to (sh.name, 3) in both the create list and copy_worksheet macro but that just produced a list with some duplicates.

    When running main and calling the copy_worksheet macro, only one file is generated (containing all the worksheets) with the name of the first worksheet from current workbook . After that I get a Path/File Access Error.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It will be difficult to build a list of names because all the three letter names will appear in the list twice.

  9. #9
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    Hi again

    How about a change of tack on this one..

    Say I have 4 workbooks each with the same sheet name in each.

    (e.g. WB1.xls has sheet 'AG', as does WB2.xls and so on.)

    Is it possible that grab each worksheet with the same name from each workbook and save them together in one workbook? Please note that some sheets will have 3 initiaals instead of 2.

    I figure that this script could be modified and looped to work with the copy script perhaps?

    Cheers

    Danny

    Please Login or Register  to view this content.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Just physically copy each sheet to a new workbook if they match, or combine the data on each sheet to one?

  11. #11
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    That would be easiest, but considering I have 105 sheets x 4 workbooks - I'm having to manipulate around 420~ worksheets effectively. I wish they could be merged, but unfortunately they need to stay as separate worksheets.

    At the moment (via macros and userforms) I am just importing these 4 large workbooks into one giant workbook and getting excel sort/add the suffixes (2), (3) etc. Then I am saving each worksheet as an individual workbook after which, a file/sheet listing is produced. This list is then automatically printed to the default printer.

    Using the file list I manually have to recombine the sets of files into new workbooks (or 'Packs' as I can them) takes hours though.

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    maybe you could use a macro to first go through the first workbook and create individual workbooks in a subdirectory. Then use a separate macro to then open each remaining workbook match the sheets to the relevant workbook & copy the data to the end of each workbook's sheet.

  13. #13
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    Someone here has changed their mind and would rather work from one source, in that case I don't need to match from other workbooks.

    In that sense its very easy for me to import all the worksheets into one workbook and create an array to select several sheets which I then bolt more code onto.

    I've implemented this so far but the array only works when 4 sheets are present for each person - anything less is 'outside the range'

    I'm a bit confused about the whole redim/preserve/erase thing. How could I rewrite this so excel knows to look to check for multiple arrays. Nesting this would be ok.

    My four arrays would be.. (and I realise you wouldn't define them like this)

    Please Login or Register  to view this content.

    Cheers


    Danny

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 11-11-2008 at 09:33 AM.

+ 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. Creating a series of workbooks from single workbook
    By AndrewCrisp in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-05-2009, 01:11 PM
  2. Collecting Worksheets into one Workbook
    By RiverSide in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2008, 11:29 AM
  3. Locking single sheet in workbook
    By scottimus in forum Excel General
    Replies: 3
    Last Post: 04-29-2008, 02:31 PM
  4. Macro moves out of Active WorkBook. Why?
    By ulfah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2008, 01:14 PM
  5. Closing the workbook & saving automatically
    By mwc0914 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-25-2008, 06:18 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