+ Reply to Thread
Results 1 to 17 of 17

Copy column data from multiple worksheets to single worksheet based on header criteria

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Copy column data from multiple worksheets to single worksheet based on header criteria

    Hi,

    I've spent about an hour searching this forum and the internet, but I can't seem to find someone with the exact same situation. I have a workbook with many sheets of similar but not identical data. I need to extract columns from each sheet based on 5 header criteria and paste them to a single sheet. Each worksheet contains these 5 criteria.


    I've been working with the VBA script I've pasted below. It's grabbing the 5 column criteria that I have in sheet 12, and comparing them to sheet 1 in the workbook, then copying them to sheet 12. This much is good, but I need the script to also return the data from the other worksheets as well. I've tried modifying the script based on other loop functions in other scripts I've found, but I'm not having any luck.

    Please Login or Register  to view this content.
    Last edited by arlu1201; 10-21-2013 at 12:53 PM. Reason: Use code tags as per rule 3.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. In order to put code tags, either type [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] at the end of it, OR you can highlight your code and click the # icon at the top of your post window.

    Will the 5 columns be constant or the same in all the sheets? Why do you want to search each time? Wont they be in the same location each time the report is prepared?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    10-17-2013
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Thanks for the welcome, and I apologize for not reading the rules more carefully. I will use the code tags in the future, for sure. I also apologize for my tardiness in reply, I've been traveling without internet for several days.

    The text of the 5 column headers that I am trying to grab are the same; however, the order and number of columns will vary from sheet to sheet. This means, for example, one of my desired columns may be in column 4, or may be in column 7, depending on how that sheet was generated, which is beyond my control.

    I don't totally understand your question, and I think it's probably because I wasn't clear enough in the original post. To restate hopefully with more clarity, I want to run this process once, to process a number of sheets with similar yet different structures and assemble the data in a single sheet based on my 5 column criteria.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Can you attach a workbook with some sample data showing before and after result. To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  5. #5
    Registered User
    Join Date
    10-17-2013
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Example.xlsm

    I've attached a file. What's going on here is the first sheet is building different urls that will query google places API and return results based on differing keywords for businesses in a specified geographic radius. Then, I have a macro that creates a new worksheet, grabs a URL from the first worksheet, runs a web query with that URL, which returns an xml table that is populated in the newly created worksheet. There are 8 urls, so 8 worksheets are created. The problem is that some businesses return different parameters, so you will find all the worksheets are largely similar, but some have different columns that the others may or may not have, so consequently, there is not an exact similar structure shared amongst the worksheets.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    I'm a bit confused. In post #1 you wanted to consolidate information in Sheet12, by identifying the proper heading in each sheet and aligning in up to the format in Sheet12? The attachment doesn't reflect that. Or maybe I'm way off?

  7. #7
    Registered User
    Join Date
    10-17-2013
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Sorry, I modified the workbook to make it more understandable, but apparently failed, haha. If you add a worksheet to the one I attached at the far right, it'll become sheet 10, so consider that the sheet that should be referenced by that code if the code I originally posted is to be used.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    OK. What are the five Column Headers to pull from in each sheet? How should they appear in Sheet 10.

  9. #9
    Registered User
    Join Date
    10-17-2013
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Example_edited.xlsmAh! I'm really sorry for being so obtuse. I've redone the worksheet, and have included the 5 headers in worksheet titled "master". It's attached.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Does this do what you want? Again I might be way off.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-17-2013
    Location
    Pittsburgh, USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Flawlessly. Thank you, very much, John!

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    You're welcome. Glad to help out and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

  13. #13
    Registered User
    Join Date
    03-20-2014
    Location
    Indiana, US
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Hi. This is my first forum post... I have a similar requirement to the above and I am not familiar with using VBA in Excel. I need to generate a report from multiple sheets/tabs in a single workbook. There is specific criteria to follow when extracting to the report i.e each tab represents a Task assigned to a team and within that specific task there are action items assigned to one or more team members. Each tab is the same layout with a header row for the range to search and within the range there are action items identified and Open/Close status assigned. I need to update a report with only Open Action Items while also identifying the tab it came from (on another worksheet) after I have updated each tab with the most recent information. I know there is a way... I just haven't learned enough about Excel to do it myself yet. Can you help?

  14. #14
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Can you attach a sample file with some dummy data? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  15. #15
    Registered User
    Join Date
    03-20-2014
    Location
    Indiana, US
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    9 Box Tasks - Tool V1.0 UNIX 20MAR14.xlsm

    Here's a sample John.

    Thanks,
    Angie

  16. #16
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    Angie. Perhaps you should start a new thread for this. Others who may be able to help may overlook because the thread is marked as SOLVED. BTW what determines an Open item?

  17. #17
    Registered User
    Join Date
    03-20-2014
    Location
    Indiana, US
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Copy column data from multiple worksheets to single worksheet based on header criteria

    John, I can start a new thread... but it will be later today. I determine open tasks from the task tab and status, then open actions for each task is on the specific tab for the task listed as a action item and Open status.

+ 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. I need to move data from main worksheet into multiple worksheets based on a criteria
    By ksenia81 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2012, 05:45 PM
  2. [SOLVED] Copy data across multiple worksheets (based on three criteria)
    By yunesm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-17-2012, 12:53 AM
  3. Replies: 1
    Last Post: 01-06-2012, 06:18 AM
  4. Copy and paste autofilter data based on multiple criteria to another worksheet
    By loneman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-04-2012, 03:05 PM
  5. VBA Copy Column data based on multiple dynamic criteria
    By rotolytics in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-19-2011, 07:26 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