+ Reply to Thread
Results 1 to 19 of 19

Merge multiple sheets data into one worksheet based on multiple criteria

  1. #1
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Merge multiple sheets data into one worksheet based on multiple criteria

    I am looking for a help to combine 2 worksheet data for non-identical headers.

    Click Search provider button on ribbon and enter search criteria (For example Quba) and click search. Below listbox1 will give the list of provider per year. When a user click any of the months (For example Al Dar Hospital (Quba) - 2015) the textbox grab that clicked text i.e. Al Dar Hospital (Quba) – 2015.

    Now what I am requesting here is when I click Export Data button then VBA Macros will look for that text value on both the worksheets i.e. Data & Resubmission Adjustment and copy entire rows on below conditions.

    1. From Worksheet data copy the entire row where the text value match.
    2. From Worksheet “Resubmission Adjustment” look for the text value and look for batch no. In column B which is present in Worksheets “Data” in column G and Worksheet “Resubmission Adjustment” in column D cell value is Resubmission Adjustment copy only those rows.

    After matching all the criteria and copy the rows and past it to the worksheet(“Statement”).

    To understand the request better I am attaching the sample file (Demo).
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Hi, I think I understand what you want.
    Just a question. What happens with the data already present in the target sheet?
    Leave it and append new data or delete contents first and copy the new values?
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Thanks Keeb for responding.

    Leave the data as it is for referring. what I need here is the textbox value should be looked into both sheets and copy the rows into a statement.

    But there is condition while copying the data from second sheet i.e. Resubmission Adjustment (Point 2).

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    I hope this is what you expected.
    Let me know if it works.

  5. #5
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Hai Keeb,

    I think I haven't explained properly this is totally different output.

    What I need here is look for textbox values in both worksheets and copy data into statements from both worksheets but in below conditions.

    1. From Worksheet data copy the entire row where the text value match.
    2. From Worksheet “Resubmission Adjustment” look for the textbox value and copy only those row where the batch no. In column B which is present in Worksheets “Data” in column G and Worksheet “Resubmission Adjustment” in column D cell value is Resubmission Adjustment.

    I hope you got me explanation properly.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Weel I guess your explanation is not clear to me:
    You have Quba as first textbox value.
    The you can select either one of the values in the first Listbox
    The second Listbox shows a list of items
    and the Last textbox shows the vlaue 'Al Dar Hospital (Quba) - 2015' if I select 2015

    Based upon that value you already filtered ALL the rows but you were asking for a filter on batch number AND where the value in column D of Resubmission Adjustement worksheet is Resubmission Adjustement

    Well according to the macro result that is what it does.

    If this is not what you require I suggest you mark the rows of data you expect to get as a result.

    You are the one that understands your data best

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    If you set the auto filter to your requirements then you get the same result.

    I filtered Data on Quba 2015
    I filetered Resubmission on that worksheet as well as Quba
    I the filtered the Batch No. and Resubmisson.

    Result: three records!

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Have you checked and see if I missed something?

  9. #9
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    I am sorry for that.

    Here is the explanation.

    Let say the textbox value is = Al Dar Hospital (Quba) - 2015 the all the rows which is having this values will be extracted from worksheet (Data) to the worksheet (Statement) (See the attachment in my first post). Then see those batch no. in worksheet (Resubmission Adjustment) in column B and same worksheet column D if the values are Resubmission Adjustment copy only those row from worksheet (Resubmission Adjustment) to worksheet (statement).

    I hope this time I have explained correctly to make you understand. kindly see my first post with the attachment showing what is the output result in worksheet (Statement).

    then look for the sale value in

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Well it's a little clearer now, so let me repeat and correct me if I am wrong:
    Step 1. Make a selection in the User form
    Step 2. Select 'Al Dar Hospital (Quba) - 2015'
    Step 3. Press Export and copy ALL data for 'Al Dar Hospital (Quba) - 2015' to Statement worksheet
    Step 4. Now cross-check the Batch No in Statement and look for that in Resubmission worksheet and only copy the data in Resubmission IF the Batch No is = and the value in column D I think you said is 'Resubmission Adjustment'

    Please verify or cirrect me before I start on something entirely different.

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    See attached Statement worksheet end explain what you need.
    Open the file and see what I mean
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    I need to the data just below i.e. 13 row.

    means after collecting the data from worksheets (data) it will continue copy the rows from the other sheets.

    Keeb it is possible to return the data in each column means batch no. in column G settlement type in column J so on...

    Sample data is attached so that we can finish it once for all.
    Attached Files Attached Files
    Last edited by hecgroups; 01-04-2016 at 11:48 AM.

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Okay, this is clear now.

  14. #14
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Well, I made the corrections and I think this is the result you wanted.
    I had to add some variables but in general it's still the same code you had with a minor addition for the extra data rows.

  15. #15
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    This is the result I want but sometime it is hard to explain in words what is in your mind.

    Thank Keeb I will apply on my original data and get back to you.

    thanks once again.

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    You're welcome.
    The best is to always include a sample with what you have and what you want to see as result like the Statement2 file, that showed me the result you wanted.
    Hope it works when you apply it to the original data file.

  17. #17
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Hai keeb. it works on my original data thanks for all your efforts which you have done for helping me.

    I have another question related to same file but not related to the topic. if you help me I will post my question.

    if not I will marked this topic as solved and reputation will be added to your account.

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Post your question and see what I can do.
    You can also psot a new question and mark this one solved, your choice

  19. #19
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: Merge multiple sheets data into one worksheet based on multiple criteria

    Thanks for the advice I think it is better to marked this topic as solved. I will PM you the new topic link.

    Thanks for your help once again.

+ 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] VBA Code to copy different data from one sheet to multiple sheets based on criteria
    By eharwood in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-08-2014, 02:22 PM
  2. [SOLVED] Lookup and sum multiple values based on a single criteria in multiple sheets.
    By paulsanett in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-17-2014, 12:18 PM
  3. Compare and Merge Data from Multiple Sheets in a worksheet
    By joeexcell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-07-2012, 09:08 PM
  4. Merge multiple excels with multiple sheets in a master excel with multiple sheets
    By marchi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2012, 10:37 AM
  5. Search multiple sheets for value based on criteria and copy data accordingly
    By Zagadka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2012, 08:46 AM
  6. Replies: 0
    Last Post: 07-27-2011, 01:00 AM
  7. Copy data from multiple sheets based on certain criteria!!
    By missyk77 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-24-2010, 12:05 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