简体   繁体   中英

How do I perform lookup or an indexed match in Excel?

In a Worksheet I have a large list of Clients (eg in column A) each with their own specific project number (in column B).

In another Worksheet within the same Workbook I would like to display in one cell (eg B1 ) the exact project number that corresponds with the name of the client I input into another cell (eg A1). If I input a client name that doesn't show up on my client list, nothing will display.

Let me see if I understood you correctly.

You can use the VLOOKUP function:

(in cell B1)
=IFERROR(VLOOKUP(A1, LookupSheet!A:B, 2, FALSE), "")

In VLOOKUP , the 2 in the third argument states that if the lookup value in A1 is found in the first column of the lookup range, you want to return the value in the second column. The fourth argument FALSE forces the match to be exact (this also makes sure that you don't have to sort the list).

If the lookup fails, then VLOOKUP returns #N/A . The IFERROR function checks if the first argument gives an error, such as #N/A - if not it returns the value, otherwise it returns the second argument ( "" ).

You can just write a VLOOK function in the B1 cell. You have to set the parameters

VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

In your case these are the parameters:

  • lookup_value = A1
  • table_array = the first two column of the tab where you have the list of clients and ID
  • col_index_num = 2
  • range_lookup = 0

In the end, you can just take a glance at these page 1 and page 2 to have an idea of how this function works.

Enter client name in cell A1 on second Worksheet. Assume the data is on a sheet called Data

In cell B1 , enter: =IFERROR(INDEX(Data!B:B,MATCH(A1,Data!A:A,0)),"")

Breaking this down:

=IFERROR({function} ,"") this says if my function returns an error, print nothing INDEX(Data!B:B, MATCH(A1,Data!A:A ,0)) this has two args:

  1. The data you wish to reproduce is from column B on Worksheet 'Data'
  2. The MATCH function (see below)

MATCH(A1,Data!A:A,0) has three args:

  1. The name to match is in cell A1 on the same Worksheet
  2. The Range to find that name in is on Worksheet named 'Data' in column A
  3. The 0 indicates that only exact matches should be accepted

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM