+ Reply to Thread
Results 1 to 3 of 3

Match Data between 2 Sheets and Transfer Data

  1. #1
    Registered User
    Join Date
    11-28-2011
    Location
    Singapore, Singapore
    MS-Off Ver
    Excel 2007
    Posts
    19

    Match Data between 2 Sheets and Transfer Data

    Hi,

    I have a Sheet "Form" with Column A (Name), B (Age), C (Blood Type), D (Staff) and E (ID). Data is available in col. A, B, C & D. IF column D shows "Yes", I need to match field A, B & C to another Sheet "Source". If there is a match for all 3, the data ID would be transferred from Sheet "Source" to "Form".

    I have attached an example, showing the "Form" Before & After the macro, and the "Source" Sheet.

    I have also tried writing a code but doesn't seem to work, any ideas?


    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Match Data between 2 Sheets and Transfer Data

    You could use this:

    =IF(D2="Yes", IFERROR( INDEX(Source!D:D,MATCH($A2&$B2&$C2,Source!$A:$A&Source!$B:$B&Source!$C:$C,0)),"staff-not found"),"not staff")

    Committed with Ctrl-Shift-Enter (Array Entered)


    That formula specifically identifies the "not found" or "not checked" scenarios.

    It is more usual to just have something like:

    =IF(D2="Yes", IFERROR( INDEX(Source!D:D,MATCH($A2&$B2&$C2,Source!$A:$A&Source!$B:$B&Source!$C:$C,0)),""),"")


    However, as both variants of this formula lookup whole columns, the calculation will be slow.

    I would therefore recommend:

    =IF($D2="Yes", IFERROR( INDEX(Source!$D$2:$D$6,MATCH($A2&$B2&$C2,Source!$A$2:$A$6&Source!$B$2:$B$6&Source!$C$2:$C$6,0)),"staff-not found"),"not staff")

    This is also committed with Ctrl-Shift-Enter but will be much quicker. You will have to adjust the ranges to reflect your data.

    It will display as:

    {=IF($D2="Yes", IFERROR( INDEX(Source!$D$2:$D$6,MATCH($A2&$B2&$C2,Source!$A$2:$A$6&Source!$B$2:$B$6&Source!$C$2:$C$6,0)),"staff-not found"),"not staff")}


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    holin_168
    Guest

    Re: Match Data between 2 Sheets and Transfer Data

    I just wonder why do you need to use VBA code? Since Ms Excel VBA or macro is very harmful so some user may not enabled macro so the VBA code will have problem. VBA code will be useful when Ms Excel formula can't meet requirement or it may to complex.

    I have a similar post at Mr. Excel (my personal Excel site) I have a similar post, please go there and have a look. The solution will work with only a short and simple formula vlookup, iferror, and if only. Please see below formula:

    IF(F5="Y",IFERROR(VLOOKUP(C5&E5,Source!$A$19:$D$27,4),""),"")

    When you look to this formula you can see in Vlook up there is "&" has been used. This is because we need to verify two conditions for vlookup to translate the result. You can use more than two. Please download my file here, then it would be very easy for you to learn from it.

    Anyway you will benefit to have a simple way to extract some information from your table based on some condition as well, same post.

+ 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