+ Reply to Thread
Results 1 to 6 of 6

Merge worksheets where worksheet.name like...

  1. #1
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Merge worksheets where worksheet.name like...

    I have a whole heap of worksheets in a workbook with names like 1_1, 1_2, 1_3... 1_n, 2_1, 2_2, 2_3, 2_n....,3_1, 3_2,3_3, 3_n....

    I need to merge all the worksheets where the number before the underscore is the same.
    So, 1_1, 1_2, 1_3, 1_n will all be in the same worksheet Group1
    2_1, 2_2, 2_3...2_n will be in the worksheet Group2
    Each Group contains a variable number of sheets.


    I have tried looping like this, but it does not find any worksheets that meet the criteria and therefore does not copy anything.

    Where z = number of groups ( will be either user input or found in a cell reference)
    Please Login or Register  to view this content.
    I have attached a sample workbook.
    Any assistance appreciated.
    Attached Files Attached Files
    Last edited by anrichards22; 02-13-2015 at 02:25 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Merge worksheets where worksheet.name like...

    Perhaps,

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Merge worksheets where worksheet.name like...

    Revised Code,
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Re: Merge worksheets where worksheet.name like...

    Dave,
    Thanks for the assistance.
    I have tried your code and it works, however there are a couple of issues.

    1. I need to create the 'Group' sheets as they are required.
    2. There are more than 10 groups, so using the left(sh.name,1) will create issues when I get to Group10 and beyond.

    Any suggestions how I can overcome those issues?

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Merge worksheets where worksheet.name like...

    Try this, run GetUnique

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Re: Merge worksheets where worksheet.name like...

    Thanks Dave, I had to amend the copy part of the code because A1 was merged cell but other than that it worked perfectly.
    Can't thank you enough.

+ 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. How to merge two worksheets into one summary worksheet
    By joey27 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-22-2013, 05:49 AM
  2. Merge multiple worksheets into one worksheet
    By mpaulus in forum Excel General
    Replies: 7
    Last Post: 01-03-2013, 02:34 PM
  3. multiple worksheets, find exceptions and merge into new worksheet
    By letsxcel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 03:55 PM
  4. Replies: 1
    Last Post: 02-21-2012, 10:13 AM
  5. Find specific word in different worksheets and merge the whole row in 1 worksheet
    By mridzuani in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2009, 04:03 AM

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