+ Reply to Thread
Results 1 to 7 of 7

Macro to combine data ranges from multiple tabs

  1. #1
    Registered User
    Join Date
    07-29-2017
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    7

    Macro to combine data ranges from multiple tabs

    Hello,

    I found the below code to combine multiple worksheets into a single worksheet.

    Wanted to check if someone can assist with amending the code for me for the following please:

    - Copy a particular range from each worksheet e.g. A5 to FU38 rather than the entire worksheet
    - Copy only values and formatting as i believe if formulas are also copied over, they may break
    - Is it possible to add the sheet name from which the data is copied into column A of the combined worksheet in each row the data is pasted?
    - Can i limit the number of worksheets that the data is copied from i.e. either specify a list, provide a number of sheets to copy or perhaps the code can copy all sheets except the last 5 sheets in the workbook. As i want to use this on multiple workbooks, the last option would work best i suppose.
    - Finally, if the values in the worksheets change, can i run the macro to refresh the values?


    Thanks in advance for your help!

    __________________________________________

    Please Login or Register  to view this content.
    Last edited by exce101; 08-16-2019 at 06:47 AM.

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,743

    Re: Macro to combine data ranges from multiple tabs

    Hi

    Please wrap code into proper tags - CODE (see Forum rules #2).
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    07-29-2017
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro to combine data ranges from multiple tabs

    Quote Originally Posted by KOKOSEK View Post
    Hi

    Please wrap code into proper tags - CODE (see Forum rules #2).
    Hi!

    Apologies for that. I've just read the rules and amended my post.

    Thanks

  4. #4
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Macro to combine data ranges from multiple tabs

    Hello Exce101,

    Try the following code:-

    Please Login or Register  to view this content.
    Firstly, open a new worksheet and name it Sheet List. Next, in A1 of this new sheet, place the heading ShList. From A2 on, place the names of the worksheets that you wish to exclude. Select the list of names including the heading and in the ribbon, select Formulas and, in the Defined Names group, select Define Name from the drop down. A New Name dialogue box will appear which will show you "List" in the name box and the selected range in the "Refers to" box. Click OK. You now have the named range as shown in the code. Whilst the list is still selected, click on the Insert tab and select Table. A Create Table dialogue box will appear showing you the selected range. Make sure that you tick the "my table has headers" box. Click OK. Your named range is now in table format. You can add/remove the relevant sheets as you wish.

    The code, when run, will copy the required range from each sheet except the ones noted in the ShList. Make sure that the "Combined" worksheet is placed in the list as well as the Sheet List worksheet

    I hope that this helps.

    Cheerio,
    vcoolio.
    Last edited by vcoolio; 08-16-2019 at 07:26 AM.

  5. #5
    Registered User
    Join Date
    07-29-2017
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    7

    Re: Macro to combine data ranges from multiple tabs

    Quote Originally Posted by vcoolio View Post
    Hello Exce101,

    Try the following code:-

    Please Login or Register  to view this content.
    Firstly, open a new worksheet and name it Sheet List. Next, in A1 of this new sheet, place the heading ShList. From A2 on, place the names of the worksheets that you wish to exclude. Select the list of names including the heading and in the ribbon, select Formulas and, in the Defined Names group, select Define Name from the drop down. A New Name dialogue box will appear which will show you "List" in the name box and the selected range in the "Refers to" box. Click OK. You now have the named range as shown in the code. Whilst the list is still selected, click on the Insert tab and select Table. A Create Table dialogue box will appear showing you the selected range. Make sure that you tick the "my table has headers" box. Click OK. Your named range is now in table format. You can add/remove the relevant sheets as you wish.

    The code, when run, will copy the required range from each sheet except the ones noted in the ShList. Make sure that the "Combined" worksheet is placed in the list as well as the Sheet List worksheet

    I hope that this helps.

    Cheerio,
    vcoolio.

    Thanks for your response.

    I have followed the steps you have listed above but the code seems to be failing at the below line:

    sh.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlValues

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,927

    Re: Macro to combine data ranges from multiple tabs

    crossposted: https://www.mrexcel.com/forum/excel-...-all-tabs.html

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. I have added them for you today. Please observe this requirement in the future as it has disturbed and wasted some of our members time already.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  7. #7
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Macro to combine data ranges from multiple tabs

    What error message are you receiving?

    Cheerio,
    vcoolio.

+ 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. [SOLVED] Combine multiple workbooks with multiple tabs onto a master workbook
    By loumarday in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-31-2016, 12:33 PM
  2. [SOLVED] Combine Data from Multiple Tabs
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2016, 01:04 PM
  3. [SOLVED] New to Excel programming. In need of a macro to combine multiple files with multiple tabs.
    By nflores0303 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-12-2016, 11:03 AM
  4. Percentile ranges - keeping data & ranges seprately in different tabs
    By Santhoshhrishi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-11-2014, 10:09 AM
  5. Combine data on multiple tabs having variable number of rows
    By noorie007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-27-2014, 05:20 PM
  6. Combine data multiple tabs into one Summary Tab
    By rorybecers in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2011, 05:59 PM
  7. Multiple Tabs - Data combine
    By zero760 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-30-2005, 04:15 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