+ Reply to Thread
Results 1 to 10 of 10

Search for a match on a different sheet and if true then copy a cell from the sheet

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    London
    MS-Off Ver
    Excel 2012
    Posts
    5

    Search for a match on a different sheet and if true then copy a cell from the sheet

    Hi,
    I am going round and round but not getting the results I am after.

    I have 2 worksheets. Worksheet 1 contains a list of reference numbers, and names. Worksheet 2 contains a list of invoices along with reference numbers. The reference numbers are the common link between the 2 sheets.

    On the 2nd worksheet I have a column and I need it to be populated by the correct name from worksheet 1. I need it to search worksheet 1 for the same reference number and when it does copy the value of the name cell on the same row to sheet 2.

    eg:
    Sheet 1

    A B
    1234 John Smith
    1292 Tom Jones
    1254 Bill Smith
    1341 A. Nother

    On worksheet 2:
    A B
    100.00 1341
    19.99 1292
    27.14 1254

    Hope this makes sense.

    Thanks

    Matt

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    You can use INDEX & MATCH functions.

    http://www.contextures.com/xlFunctions03.html


    Edit: Something like this.

    =INDEX(Sheet1!B:B,MATCH(Sheet2!B1,Sheet1!A:A,0))
    Last edited by Fotis1991; 09-25-2012 at 08:55 AM. Reason: Edit
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    09-25-2012
    Location
    London
    MS-Off Ver
    Excel 2012
    Posts
    5

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    Thanks for your quick reply.

    I entered =INDEX('Download Purchase Lines'!H:H,MATCH(B4,'Download Purchase Lines'!C:C,0))

    I also tried: =INDEX('Download Purchase Lines'!H:H,MATCH('June 2012'!B4,'Download Purchase Lines'!C:C,0))

    But all I am getting is N/A

    I have checked the common reference number is present.

    Am I missing something obvious?

    Man thanks again

    Matt

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    ...I have checked the common reference number is present.

    Am I missing something obvious?

    Then, pls, upload a small sample workbook.

  5. #5
    Registered User
    Join Date
    09-25-2012
    Location
    London
    MS-Off Ver
    Excel 2012
    Posts
    5

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    Hi,

    Many thanks again. I have attached some sample data.

    Thanks again

    Matt
    Attached Files Attached Files

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    Try this and try to understand how formula works.

    =INDEX('Download Purchase Lines'!B:B,MATCH($B4,'Download Purchase Lines'!G:G,0))

  7. #7
    Registered User
    Join Date
    09-25-2012
    Location
    London
    MS-Off Ver
    Excel 2012
    Posts
    5

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    Many thanks Fotis,

    Is there any reason I would still get N/A when I run it on full live data, but not when use the test data I created?

    Thanks again

    Matt

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    Yes. You get N/A, where match, find nothing!

    Try

    =iferror(INDEX('Download Purchase Lines'!B:B,MATCH($B4,'Download Purchase Lines'!G:G,0)),"")

  9. #9
    Registered User
    Join Date
    09-25-2012
    Location
    London
    MS-Off Ver
    Excel 2012
    Posts
    5

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    You are brilliant.

    Many thanks.

    Matt

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Search for a match on a different sheet and if true then copy a cell from the sheet

    You are welcome Matt!

    Thanks for the reb*

+ 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