+ Reply to Thread
Results 1 to 14 of 14

Need to get data from several small tables into one large table

  1. #1
    Registered User
    Join Date
    11-28-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Need to get data from several small tables into one large table

    I have a series of tables. All share a set number of columns but the number of rows of data varies between each table. Each table has a header and column labels. There is always a blank row between the table heading and the row with column labels and there is always a blank row between the last row of data in a table and the heading for the next table. They look something like this:

    Group A
    Column Label 1 Column Label 2 Column Label 3
    Data 1-1 Data 1-2 Data 1-3
    Data 2-1 Data 2-2 Data 2-3
    Data 3-1 Data 3-2 Data 3-3
    Group B
    Column Label 1 Column Label 2 Column Label 3
    Data 4-1 Data 4-2 Data 4-3
    Data 5-1 Data 5-2 Data 5-3
    Data 6-1 Data 6-2 Data 6-3
    Data 7-1 Data 7-2 Data 7-3
    Data 8-1 Data 8-2 Data 8-3
    Group C
    Column Label 1 Column Label 2 Column Label 3
    Data 9-1 Data 9-2 Data 9-3
    Data 10-1 Data 10-2 Data 10-3






    I would like to find a way to consolodate everything into one large table with the column headers and spaces between tables removed. I would like to retain the table headers as part of the data.

    The desired output is something like:

    Data 1-1 Data 1-2 Data 1-3 Group A
    Data 2-1 Data 2-2 Data 2-3 Group A
    Data 3-1 Data 3-2 Data 3-3 Group A
    Data 4-1 Data 4-2 Data 4-3 Group B
    Data 5-1 Data 5-2 Data 5-3 Group B
    Data 6-1 Data 6-2 Data 6-3 Group B
    Data 7-1 Data 7-2 Data 7-3 Group B
    Data 8-1 Data 8-2 Data 8-3 Group B
    Data 9-1 Data 9-2 Data 9-3 Group C
    Data 10-1 Data 10-2 Data 10-3 Group C




    I hope I've demonstrated this well enough. I am very inexperienced with Excel's higher functions such as macros but hope that the solution to this problem is one that will help me learn.
    Last edited by Haze01; 11-29-2013 at 11:21 PM. Reason: Marking thread as solved.

  2. #2
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,007

    Re: Need to get data from several small tables into one large table

    Hi,
    "Pivot Table" or "Power Pivot Add-In" are useful tools for your needs.
    Best Regards.

  3. #3
    Registered User
    Join Date
    11-28-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Need to get data from several small tables into one large table

    Thank you for the suggestion. I guess I really am quite bad at using Excel; I can't seem to get anything useful going when trying to set up pivot tables for this problem. The Power Pivot Add-In certainly sounds good, reading a little about it, but I'm on a work computer and it would be preferred to not have to download and install anything.

  4. #4
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,007

    Re: Need to get data from several small tables into one large table

    Hi Haze01,
    If you add a sample file here I will try to help you...

  5. #5
    Forum Contributor
    Join Date
    08-22-2013
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Need to get data from several small tables into one large table

    Quote Originally Posted by Haze01 View Post
    Thank you for the suggestion. I guess I really am quite bad at using Excel; I can't seem to get anything useful going when trying to set up pivot tables for this problem. The Power Pivot Add-In certainly sounds good, reading a little about it, but I'm on a work computer and it would be preferred to not have to download and install anything.
    Hi Haze01,

    The pivot table function is already part of Excel so you wouldn't need to download anything for that option.
    Pivot tables allow you to organise the data in any order you like as well, so you could keep your current tables in one sheet and just update them whenever you need to, and then go and refresh your pivot table and it will automatically include the updated data.
    You can also add and remove certain values or headings from a pivot table by ticking or unticking check boxes in the pivot table options that pops up when the table is selected.

  6. #6
    Registered User
    Join Date
    11-28-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Need to get data from several small tables into one large table

    @HerryMarkowitz, thank you, I would appreciate your help. I had hoped that the sample tables I provided in the body of my initial post would have been clear enough but I will simply attach the spreadsheet I am working on here.

    @alexander.small, I'm afraid the data I have is not already in a pivot table so there is nothing associating the table headings with the data below it. I understand that I might be able to leverage the built-in pivot table functions to solve my problem but I really don't know just how to do so. I can't simply select all of the data and create a pivot table from that selection. I think it is more likely that an intelligent macro will be the solution for transforming the data but my earliest attempts at one have all failed.

    I note that a similar thread from a year ago went unsolved. The author of that thread was looking to combine three tables from three separate worksheets into one large table on a fourth worksheet. His data seems better organized than what I'm working with, but it's interesting to see a similar problem. The thread is: Is it possible to merge multiple tables into one large table?

    I have now attached the spreadsheet I am attempting to manipulate in this way. As I was doing so, I found another way to rephrase my problem:
    I would like to consolodate all of the data from several tables into one large table. Each of the small tables has the same number of columns, a table header describing the contents of the table, column headers, and a varying number of rows of data. To do so, I am looking for a way to automate the following tasks:
    - Put the table headers into a new column alongside the data
    - Remove the column headers
    - Remove empty spaces between tables, effectively merging all tables into one large table
    Attached Files Attached Files
    Last edited by Haze01; 11-29-2013 at 04:24 PM.

  7. #7
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,007

    Re: Need to get data from several small tables into one large table

    Try enclosed file...
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-28-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Need to get data from several small tables into one large table

    This is getting somewhere now, thank you. Right now, we have two of the three main tasks handled by the macro:
    - Remove the column headers
    - Remove empty spaces between tables, effectively merging all tables into one large table

    To solve the remaining bit (putting the table headers into a new column alongside the data) we need to:
    1) Have the macro identify what is a table header - I can see that table headers always appear as the contents of column A in a row with nothing in column B. No other rows have something in column A and nothing in column B.
    2) Copy the value found in that cell.
    3) Delete that row.
    4) Paste the copied value into column E for the new row.
    5) The macro then needs to check if the next row contains a table header (by having a value in column A and nothing in column B).
    6) If it doesn't contain a table header, go to 4. If it does contain a table header, go to 2.
    Last edited by Haze01; 11-29-2013 at 09:19 PM.

  9. #9
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,007

    Re: Need to get data from several small tables into one large table

    Try the last one...
    Dont forget checking if everthing is okey or not !
    Attached Files Attached Files
    Last edited by HerryMarkowitz; 12-01-2013 at 06:48 AM.

  10. #10
    Registered User
    Join Date
    11-28-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Need to get data from several small tables into one large table

    Thank you, it works perfectly.

    I took some time to think about what each line of code in the macro is doing. I can follow it up to this point and then I'm not sure just why it does what it does. Would you mind walking me through what is happening here?

    Please Login or Register  to view this content.
    I really appreciate your help with this and any further understanding you can impart to me would also be appreciated.

  11. #11
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,007

    Re: Need to get data from several small tables into one large table

    Following line fills blanks with formula which brings value from one cell above...
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    11-28-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Need to get data from several small tables into one large table

    Ah, I just figured it out. The lines of code before the ones I posted above added references to the table headings from column A into certain cells in column E.

    Lines 1 and 2 of the code I highlighted above first copy the contents of column E and then paste the values back into place so that they are no longer referencing the original table headings (which will later be deleted by other lines of code).

    Line 3 then finds all the blank cells and tells them to be the cell above it.

    Lines 4 and 5 copy the contents of column E again and paste the values so that the newly added data from line 3 is no longer referencing anything.

    Thank you again for your help!

  13. #13
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,007

    Re: Need to get data from several small tables into one large table

    You are welcome.
    Last edited by HerryMarkowitz; 12-01-2013 at 06:48 AM.

  14. #14
    Registered User
    Join Date
    11-28-2013
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Need to get data from several small tables into one large table

    I added reputation to you when you put in your first crack at it with Excel Problem2.xls and I tried to give you more when I saw Excel Problem3.xls but it didn't let me. It tells me I have to spread some around before giving more to you :-/

    I've been on other forums where you can see when a post has been "liked" and how many times so I'm surprised that this forum doesn't have that kind of feedback with it's reputation feature; it seems neither of us can tell that reputation was given out for that earlier post even though I know I did it.

+ 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. Replies: 3
    Last Post: 12-06-2012, 10:51 AM
  2. Replies: 6
    Last Post: 09-27-2012, 10:45 AM
  3. Replies: 14
    Last Post: 05-23-2012, 08:09 PM
  4. create small tables from a large table
    By ruleworld in forum Excel General
    Replies: 4
    Last Post: 08-01-2010, 04:43 AM
  5. Identifying small tables in one large table
    By Nick_in_Dubai in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-25-2009, 12:01 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