+ Reply to Thread
Results 1 to 13 of 13

VBA helps needed to consolidate data from multiple sheets by matching Column header

  1. #1
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Folks,

    I have several sheets in my Workbook. All have matched columns headers but in different order.
    I need to copy all the row data from all sheets to “Consolidated_Data” sheet. Is there any way to copy the data exactly under matching column headers?

    My small example workbook can describe better.


    Thanks in advance for your time.

    Joshi
    Attached Files Attached Files
    Last edited by krjoshi; 01-29-2013 at 12:52 PM.
    Cheers,

    Joshi
    Being with a winner makes you a winner

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Joshi,
    try it

  3. #3
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Nilem,

    Thank you so much, its working great. Some minor issues, if I set only a single column header in "Consolidated_Data" sheet then the code giving debug message (see the attached file). Also I want to clear all format if the column header is blank.

    Can you please check and help me to fix the issues.

    Thanks in advance.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi,

    Try the attached.

    It uses the following macro with the helper row on the consolidated sheet
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Richard Buttrey,

    Thank you so much for your time and advice. Still some issues, in your codes the data is copying with row header which I doesn't required. And not comfort with the helper row (formula) on the consolidated sheet since I have to edit all the times if I add more sheets. I prefer Nilem's code with slight modification which I requested in my first reply. Could you please help me to fix the issue.

    Thanks in advance,
    Joshi

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi,

    You may be mistaken. There's no need to change the helper row just because you add new sheets.
    Actually Nilem's approach and mine are very similar. Whereas he holds the column labels in a VBA array, I chose to use the helper row approach.

    I left the row header in place so that you could satisfy yourself that it was consolidating correctly. Just change the macro to compensate if you don;t want it, or filter the consolidated data for a row header and delete the filtered rows.

  7. #7
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Joshi,
    maybe so

  8. #8
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Nilem,
    Thank you so much for your time and help. But now its only working for single column header. if I set more than one column headers its giving debug message.

    Please help me to fix this issue.

    Thanks in advance.
    Joshi

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Quote Originally Posted by krjoshi View Post
    Hi Nilem,
    ...

    Please help me to fix this issue.
    Joshi
    Just as a matter of interest have you tried the solution I gave you which is similar to Nilem's or does that result in the same problem?

  10. #10
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Richard,

    I have tried your codes and working great. But I don't want the formula (helper row) in the main sheet, because if I clear the formula by mistake then the code will give debug message. Also I don't want repeat column headers of the each sheets.

    Can you please help me to fix these issues.

    Thanks for your time and help.

    Joshi

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi,

    In that case I'll leave Nilem to respond since his code works in a similar way. He uses VBA to determine which column in each sheet is the appropriate column whereas my version uses Excel to determine the column.

    (Incidentally the helper row could be hidden or even located on another sheet if you really don't want to see it, and of course as I said the duplicate column headers can easily be removed)

    But as I say I'll let Nilem respond to his version.

  12. #12
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Quote Originally Posted by krjoshi View Post
    ... now its only working for single column header...
    Oh, it was my fault
    I hope now everything is correct

  13. #13
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA helps needed to consolidate data from multiple sheets by matching Column header

    Hi Nilem,

    Ohh great code. And working excellent. Can you please do one more favor, if I select column header same as to all columns (i.e Column "A" as "Unit" , "B" as "Unit", "C" as "Unit" I want to paste all values as same), Please help me.

    Thanks,
    Joshi
    Last edited by krjoshi; 01-31-2013 at 03:33 PM.

+ 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