If found in list excel

So, there are times when you would like to know that a value is in a list or not. We have done this using VLOOKUP. But we can do the same thing using COUNTIF function too. So in this article, we will learn how to check if a values is in a list or not using various ways.

Check If Value In Range Using COUNTIF Function

So as we know, using COUNTIF function in excel we can know how many times a specific value occurs in a range. So if we count for a specific value in a range and its greater than zero, it would mean that it is in the range. Isn’t it?

Generic Formula

=COUNTIF(range,value)>0

Range: The range in which you want to check if the value exist in range or not.

Value: The value that you want to check in the range.

Let’s see an example:

Excel Find Value is in Range Example

For this example, we have below sample data. We need a check-in the cell D2, if the given item in C2 exists in range A2:A9 or say item list. If it’s there then, print TRUE else FALSE.
1
Write this formula in cell D2:

2
Since C2 contains “scale” and it’s not in the item list, it shows FALSE. Exactly as we wanted. Now if you replace “scale” with “Pencil” in the formula above, it’ll show TRUE.
3
Now, this TRUE and FALSE looks very back and white. How about customizing the output. I mean, how about we show, “found” or “not found” when value is in list and when it is not respectively.
Since this test gives us TRUE and FALSE, we can use it with IF function of excel.

Write this formula:

=IF(COUNTIF(A2:A9,C2)>0,»in List»,»Not in List»)

You will have this as your output.
4
What If you remove “>0” from this if formula?

=IF(COUNTIF(A2:A9,C2),»in List»,»Not in List»)

It will work fine. You will have same result as above. Why? Because IF function in excel treats any value greater than 0 as TRUE.

How to check if a value is in Range with Wild Card Operators

Sometimes you would want to know if there is any match of your item in the list or not. I mean when you don’t want an exact match but any match.

For example, if in the above-given list, you want to check if there is anything with “red”. To do so, write this formula.

=IF(COUNTIF(A2:A9,»*red*»),»in List»,»Not in List»)

This will return a TRUE since we have “red pen” in our list. If you replace red with pink it will return FALSE. Try it.
Now here I have hardcoded the value in list but if your value is in a cell, say in our favourite cell B2 then write this formula.

IF(COUNTIF(A2:A9,»*»&B2&»*»),»in List»,»Not in List»)

5
There’s one more way to do the same. We can use the MATCH function in excel to check if the column contains a value. Let’s see how.

Find if a Value is in a List Using MATCH Function

So as we all know that MATCH function in excel returns the index of a value if found, else returns #N/A error. So we can use the ISNUMBER to check if the function returns a number.
If it returns a number ISNUMBER will show TRUE, which means it’s found else FALSE, and you know what that means.

Write this formula in cell C2:

=ISNUMBER(MATCH(C2,A2:A9,0))

6
The MATCH function looks for an exact match of value in cell C2 in range A2:A9. Since DESK is on the list, it shows a TRUE value and FALSE for SCALE.

So yeah, these are the ways, using which you can find if a value is in the list or not and then take action on them as you like using IF function. I explained how to find value in a range in the best way possible. Let me know if you have any thoughts. The comments section is all yours.

Related Articles:

How to Check If Cell Contains Specific Text in Excel

How to Check A list of Texts In String in Excel

How to take the Average Difference between lists in Excel

How to Get Every Nth Value From A list in Excel

Popular Articles:

50 Excel Shortcuts to Increase Your Productivity

How to use the VLOOKUP Function in Excel

How to use the COUNTIF function in Excel

How to use the SUMIF Function in Excel

I’ve got a range (A3:A10) that contains names, and I’d like to check if the contents of another cell (D1) matches one of the names in my list.

I’ve named the range A3:A10 ‘some_names’, and I’d like an excel formula that will give me True/False or 1/0 depending on the contents.

asked May 29, 2013 at 20:43

joseph.hainline's user avatar

joseph.hainlinejoseph.hainline

2,0523 gold badges16 silver badges16 bronze badges

=COUNTIF(some_names,D1)

should work (1 if the name is present — more if more than one instance).

answered May 29, 2013 at 20:47

pnuts's user avatar

1

My preferred answer (modified from Ian’s) is:

=COUNTIF(some_names,D1)>0

which returns TRUE if D1 is found in the range some_names at least once, or FALSE otherwise.

(COUNTIF returns an integer of how many times the criterion is found in the range)

pnuts's user avatar

pnuts

6,0623 gold badges27 silver badges41 bronze badges

answered Jun 6, 2013 at 20:40

joseph.hainline's user avatar

joseph.hainlinejoseph.hainline

2,0523 gold badges16 silver badges16 bronze badges

0

I know the OP specifically stated that the list came from a range of cells, but others might stumble upon this while looking for a specific range of values.

You can also look up on specific values, rather than a range using the MATCH function. This will give you the number where this matches (in this case, the second spot, so 2). It will return #N/A if there is no match.

=MATCH(4,{2,4,6,8},0)

You could also replace the first four with a cell. Put a 4 in cell A1 and type this into any other cell.

=MATCH(A1,{2,4,6,8},0)

CJBS's user avatar

answered Nov 10, 2014 at 22:57

RPh_Coder's user avatar

RPh_CoderRPh_Coder

4784 silver badges4 bronze badges

6

If you want to turn the countif into some other output (like boolean) you could also do:

=IF(COUNTIF(some_names,D1)>0, TRUE, FALSE)

Enjoy!

answered May 29, 2013 at 21:09

Ian McClellan's user avatar

1

For variety you can use MATCH, e.g.

=ISNUMBER(MATCH(D1,A3:A10,0))

answered May 29, 2013 at 23:28

barry houdini's user avatar

barry houdinibarry houdini

10.8k1 gold badge20 silver badges25 bronze badges

there is a nifty little trick returning Boolean in case range some_names could be specified explicitly such in "purple","red","blue","green","orange":

=OR("Red"={"purple","red","blue","green","orange"})

Note this is NOT an array formula

answered Jul 11, 2018 at 22:06

gregV's user avatar

gregVgregV

2042 silver badges4 bronze badges

1

You can nest --([range]=[cell]) in an IF, SUMIFS, or COUNTIFS argument. For example, IF(--($N$2:$N$23=D2),"in the list!","not in the list"). I believe this might use memory more efficiently.

Alternatively, you can wrap an ISERROR around a VLOOKUP, all wrapped around an IF statement. Like, IF( ISERROR ( VLOOKUP() ) , "not in the list" , "in the list!" ).

answered Dec 5, 2013 at 19:33

skilbjo's user avatar

0

In situations like this, I only want to be alerted to possible errors, so I would solve the situation this way …

=if(countif(some_names,D1)>0,"","MISSING")

Then I’d copy this formula from E1 to E100. If a value in the D column is not in the list, I’ll get the message MISSING but if the value exists, I get an empty cell. That makes the missing values stand out much more.

Dan Atkinson's user avatar

answered Aug 24, 2013 at 11:59

Catchoval's user avatar

0

Array Formula version (enter with Ctrl + Shift + Enter):

=OR(A3:A10=D1)

answered Dec 8, 2016 at 12:38

Slai's user avatar

SlaiSlai

1195 bronze badges

1

Author: Oscar Cronquist Article last updated on February 01, 2023

This article demonstrates several ways to check if a cell contains any value based on a list. The first example shows how to check if any of the values in the list is in the cell.

The remaining examples show formulas that also return the matching values. You may need different formulas based on the Excel version you are using.

Read this article If cell equals value from list to match the entire cell to any value from a list. To match a single cell to a single value read this: If cell contains text

To check if a cell contains all values in the list read this: If cell contains multiple values

What’s on this page

  1. Check if the cell contains any value in the list
  2. Display matches if cell contains text from list (Excel 2019)
  3. Display matches if cell contains text from list (Earlier Excel versions)
  4. Filter delimited values not in list (Excel 365)

1. Check if the cell contains any value in the list

The image above shows an array formula in cell C3 that checks if cell B3 contains at least one of the values in List (E3:E7), it returns «Yes» if any of the values are found in column B and returns nothing if the cell contains none of the values.

For example, cell B3 contains XBF which is found in cell E7. Cell B4 contains text ZDS found in cell E6. Cell C5 contains no values in the list.

=IF(OR(COUNTIF(B3,»*»&$E$3:$E$7&»*»)), «Yes», «»)

You need to enter this formula as an array formula if you are not an Excel 365 subscriber. There is another formula below that doesn’t need to be entered as an array formula, however, it is slightly larger and more complicated.

  1. Type formula in cell C3.
  2. Press and hold CTRL + SHIFT simultaneously.
  3.  Press Enter once.
  4. Release all keys.

Excel adds curly brackets to the formula automatically if you successfully entered the array formula. Don’t enter the curly brackets yourself.

Back to top

1.1 Explaining formula in cell C3

Step 1 — Check if the cell contains any of the values in the list

The COUNTIF function lets you count cells based on a condition, however, it also allows you to count cells based on multiple conditions if you use a cell range instead of a cell.

COUNTIF(rangecriteria)

The criteria argument utilizes a beginning and ending asterisk in order to match a text string and not the entire cell value, asterisks are one of two wildcard characters that you are allowed to use.

The ampersands concatenate the asterisks to cell range E3:E7.

COUNTIF(B3,»*»&$E$3:$E$7&»*»)

becomes

COUNTIF(«LNU, YNO, XBF», {«*MVN*»; «*QLL*»; «*BQX*»; «*ZDS*»; «*XBF*»})

and returns this array

{0; 0; 0; 0; 1}

which tells us that the last value in the list is found in cell B3.

Step 2 — Return TRUE if at least one value is 1

The OR function returns TRUE if at least one of the values in the array is TRUE, the numerical equivalent to TRUE is 1.

OR({0; 0; 0; 0; 1})

returns TRUE.

Step 3 — Return Yes or nothing

The IF function then returns «Yes» if the logical test evaluates to TRUE and nothing if the logical test returns FALSE.

IF(TRUE, «Yes», «»)

returns «Yes» in cell B3.

Back to top

Regular formula

The following formula is quite similar to the formula above except that it is a regular formula and it has an additional INDEX function.

=IF(OR(INDEX(COUNTIF(B3,»*»&$E$3:$E$7&»*»),)), «Yes», «»)

Back to top

Back to top

2. Display matches if the cell contains text from a list

If cell contains value from list

The image above demonstrates a formula that checks if a cell contains a value in the list and then returns that value. If multiple values match then all matching values in the list are displayed.

For example, cell B3 contains «ZDS, YNO, XBF» and cell range E3:E7 has two values that match, «ZDS» and «XBF».

Formula in cell C3:

=TEXTJOIN(«, «, TRUE, IF(COUNTIF(B3, «*»&$E$3:$E$7&»*»), $E$3:$E$7, «»))

The TEXTJOIN function is available for Office 2019 and Office 365 subscribers. You will get a #NAME error if your Excel version is missing this function. Office 2019 users may need to enter this formula as an array formula.

The next formula works with most Excel versions.

Array formula in cell C3:

=INDEX($E$3:$E$7, MATCH(1, COUNTIF(B3, «*»&$E$3:$E$7&»*»), 0))

However, it only returns the first match. There is another formula below that returns all matching values, check it out.

How to enter an array formula

Back to top

2.1 Explaining formula in cell C3

Step 1 — Count cells containing text strings

The COUNTIF function lets you count cells based on a condition, we are going to use multiple conditions. I am going to use asterisks to make the COUNTIF function check for a partial match.

The asterisk is one of two wild card characters that you can use, it matches 0 (zero) to any number of any characters.

COUNTIF(B3, «*»&$E$3:$E$7&»*»)

becomes

COUNTIF(«ZDS, YNO, XBF», {«*MVN*»; «*QLL*»; «*BQX*»; «*ZDS*»; «*XBF*»})

and returns {1; 0; 0; 0; 1}.

This array contains as many values as there values in the list, the position of each value in the array matches the position of the value in the list. This means that we can tell from the array that the first value and the last value is found in cell B3.

Step 2 — Return the actual value

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(logical_test, [value_if_true], [value_if_false])

This allows us to create an array containing values that exists in cell B3.

IF(COUNTIF(B3, «*»&$E$3:$E$7&»*»), $E$3:$E$7, «»)

becomes

IF(COUNTIF(«ZDS, YNO, XBF», {«*MVN*»; «*QLL*»; «*BQX*»; «*ZDS*»; «*XBF*»}), {«*MVN*»; «*QLL*»; «*BQX*»; «*ZDS*»; «*XBF*»}, «»)

and returns {«»;»»;»»;»ZDS»;»XBF»}.

Step 3 — Concatenate values in array

The TEXTJOIN function allows you to combine text strings from multiple cell ranges and also use delimiting characters if you want.

TEXTJOIN(delimiterignore_emptytext1[text2], …)

TEXTJOIN(«, «, TRUE, IF(COUNTIF(B3, «*»&$E$3:$E$7&»*»), $E$3:$E$7, «»))

becomes

TEXTJOIN(«, «, TRUE, {«»;»»;»»;»ZDS»;»XBF»})

and returns text strings ZDS, XBF.

Back to top

3. Display matches if cell contains text from a list (Earlier Excel versions)

If cell contains value from list show all matching values

The image above demonstrates a formula that returns multiple matches if the cell contains values from a list. This array formula works with most Excel versions.

Array formula in cell C3:

=IFERROR(INDEX($G$3:$G$7, SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1))), «»)

How to enter an array formula

Copy cell C3 and paste to cell range C3:E15.

Back to top

3.1 Explaining formula in cell C3

Step 1 — Identify matching values in cell

The COUNTIF function lets you count cells based on a condition, we are going to use a cell range instead. This will return an array of values.

COUNTIF($B3, «*»&$G$3:$G$7&»*»)

becomes

COUNTIF(«ZDS, YNO, XBF», {«*MVN*»; «*QLL*»; «*BQX*»; «*ZDS*»; «*XBF*»})

and returns {0; 0; 0; 1; 1}.

Step 2 — Calculate relative positions of matching values

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(logical_test, [value_if_true], [value_if_false])

This allows us to create an array containing values representing row numbers.

IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»)

becomes

IF({0; 0; 0; 2; 1}, MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»)

becomes

IF({0; 0; 0; 2; 1}, {1; 2; 3; 4; 5}, «»)

and returns {«»; «»; «»; 4; 5}.

Step 3 — Extract the k-th smallest number

I am going to use the SMALL function to be able to extract one value in each cell in the next step.

SMALL(arrayk)

SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1)))

becomes

SMALL({«»; «»; «»; 4; 5}, COLUMNS($A$1:A1)))

The COLUMNS function calculates the number of columns in a cell range, however, the cell reference in our formula grows when you copy the cell and paste to adjacent cells to the right.

SMALL({0; 0; 0; 4; 5}, COLUMNS($A$1:A1)))

becomes

SMALL({«»; «»; «»; 4; 5}, 1)

and returns 4.

Step 4 — Return value based on row number

The INDEX function returns a value from a cell range or array, you specify which value based on a row and column number. Both the [row_num] and [column_num] are optional.

INDEX(array[row_num][column_num])

INDEX($G$3:$G$7, SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1)))

becomes

INDEX($G$3:$G$7, 4)

becomes

INDEX({«MVN»;»QLL»;»BQX»;»ZDS»;»XBF»}, 4)

and returns «ZDS» in cell C3.

Step 5 — Remove error values

The IFERROR function lets you catch most errors in Excel formulas except #SPILL! errors. Be careful when using the IFERROR function, it may make it much harder spotting formula errors.

IFERROR(valuevalue_if_error)

There are two arguments in the IFERROR function. The value argument is returned if it is not evaluating to an error. The value_if_error argument is returned if the value argument returns an error.

IFERROR(INDEX($G$3:$G$7, SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1))), «»)

Back to top

4. Filter delimited values not in the list (Excel 365)

Display values not in cell from a list

The formula in cell C3 lists values in cell B3 that are not in the List specified in cell range E3:E7. The formula returns #CALC! error if all values are in the list, see cell C14 as an example.

Excel 365 dynamic array formula in cell C3:

=LET(z,TRIM(TEXTSPLIT(B3,,»,»)),TEXTJOIN(«, «,TRUE,FILTER(z,NOT(COUNTIF($E$3:$E$7,z)))))

4.1 Explaining formula

Step 1 — Split values with a delimiting character

The TEXTSPLIT function splits a string into an array based on delimiting values.

Function syntax: TEXTSPLIT(Input_Text, col_delimiter, [row_delimiter], [Ignore_Empty])

TEXTSPLIT(B3,,»,»)

becomes

TEXTSPLIT(«ZDS, VTO, XBF»,,»,»)

and returns

{«ZDS»; » VTO»; » XBF»}

Step 2 — Remove leading and trailing spaces

The TRIM function deletes all blanks or space characters except single blanks between words in a cell value.

Function syntax: TRIM(text)

TRIM(TEXTSPLIT(B3,,»,»))

becomes

TRIM({«ZDS»; » VTO»; » XBF»})

and returns

{«ZDS»; «VTO»; «XBF»}

Step 3 — Check if values are in list

The COUNTIF function calculates the number of cells that is equal to a condition.

Function syntax: COUNTIF(range, criteria)

COUNTIF($E$3:$E$7,TRIM(TEXTSPLIT(B3,,»,»)))

becomes

COUNTIF({«MVN»;»QLL»;»BQX»;»ZDS»;»XBF»},{«ZDS»; «VTO»; «XBF»})

and returns

{1; 0; 1}

These numbers indicate if a value is found in the list, zero means not in the list and 1 or higher means that the value is in the list at least once.

The number’s position corresponds to the position of the values. {1; 0; 1} — {«ZDS»; «VTO»; «XBF»} meaning «ZDS» and «XBF» are in the list and «VTO» not.

Step 4 — Not

The NOT function returns the boolean opposite to the given argument.

Function syntax: NOT(logical)

NOT(COUNTIF($E$3:$E$7,TRIM(TEXTSPLIT(B3,,»,»))))

becomes

NOT({1; 0; 1})

and returns

{FALSE; TRUE; FALSE}.

0 (zero) is equivalent to FALSE. The boolean opposite is TRUE.

Any other number than 0 (zero) is equivalent to TRUE.  The boolean opposite is FALSE.

Step 5 — Filter

The FILTER function extracts values/rows based on a condition or criteria.

Function syntax: FILTER(array, include, [if_empty])

FILTER(TRIM(TEXTSPLIT(B3,,»,»)),NOT(COUNTIF($E$3:$E$7,TRIM(TEXTSPLIT(B3,,»,»)))))

becomes

FILTER({«ZDS»; «VTO»; «XBF»},{FALSE; TRUE; FALSE})

and returns

«VTO».

Step 6 — Join

The TEXTJOIN function combines text strings from multiple cell ranges.

Function syntax: TEXTJOIN(delimiter, ignore_empty, text1, [text2], …)

TEXTJOIN(«, «,TRUE,FILTER(TRIM(TEXTSPLIT(B3,,»,»)),NOT(COUNTIF($E$3:$E$7,TRIM(TEXTSPLIT(B3,,»,»))))))

becomes

TEXTJOIN(«, «,TRUE,{«VTO»})

and returns

«VTO».

Step 7 — Shorten the formula

The LET function lets you name intermediate calculation results which can shorten formulas considerably and improve performance.

Function syntax: LET(name1, name_value1, calculation_or_name2, [name_value2, calculation_or_name3…])

TEXTJOIN(«, «,TRUE,FILTER(TRIM(TEXTSPLIT(B3,,»,»)),NOT(COUNTIF($E$3:$E$7,TRIM(TEXTSPLIT(B3,,»,»))))))

z — TRIM(TEXTSPLIT(B3,,»,»))

LET(z,TRIM(TEXTSPLIT(B3,,»,»)),TEXTJOIN(«, «,TRUE,FILTER(z,NOT(COUNTIF($E$3:$E$7,z)))))

Back to top

Содержание

  1. Value exists in a range
  2. Related functions
  3. Summary
  4. Generic formula
  5. Explanation
  6. COUNTIF function
  7. Slightly abbreviated
  8. Testing for a partial match
  9. An alternative formula using MATCH
  10. How do I use a nested IF(AND) in an Excel array formula?
  11. Excel — Find a value in an array and return the contents of the corresponding column
  12. 4 Answers 4
  13. Excel if found in array
  14. What’s on this page
  15. 1. Check if the cell contains any value in the list
  16. 1.1 Explaining formula in cell C3
  17. Step 1 — Check if the cell contains any of the values in the list
  18. Step 2 — Return TRUE if at least one value is 1
  19. Step 3 — Return Yes or nothing
  20. Regular formula
  21. Get the Excel file
  22. 2. Display matches if the cell contains text from a list
  23. 2.1 Explaining formula in cell C3
  24. Step 1 — Count cells containing text strings
  25. Step 2 — Return the actual value
  26. Step 3 — Concatenate values in array
  27. 3. Display matches if cell contains text from a list (Earlier Excel versions)
  28. 3.1 Explaining formula in cell C3
  29. Step 1 — Identify matching values in cell
  30. Step 2 — Calculate relative positions of matching values
  31. Step 3 — Extract the k-th smallest number
  32. Step 4 — Return value based on row number
  33. Step 5 — Remove error values
  34. 4. Filter delimited values not in the list (Excel 365)
  35. 4.1 Explaining formula
  36. Step 1 — Split values with a delimiting character
  37. Step 2 — Remove leading and trailing spaces
  38. Step 3 — Check if values are in list
  39. Step 4 — Not
  40. Step 5 — Filter
  41. Step 6 — Join
  42. Step 7 — Shorten the formula
  43. Logic category
  44. Functions in this article
  45. Excel formula categories
  46. Excel categories
  47. 48 Responses to “If cell contains text from list”

Value exists in a range

Summary

To test if a value exists in a range of cells, you can use a simple formula based on the COUNTIF function and the IF function. In the example shown, the formula in F5, copied down, is:

where data is the named range B5:B16. As the formula is copied down it returns «Yes» if the value in column E exists in B5:B16 and «No» if not.

Generic formula

Explanation

In this example, the goal is to use a formula to check if a specific value exists in a range. The easiest way to do this is to use the COUNTIF function to count occurences of a value in a range, then use the count to create a final result.

COUNTIF function

The COUNTIF function counts cells that meet supplied criteria. The generic syntax looks like this:

Range is the range of cells to test, and criteria is a condition that should be tested. COUNTIF returns the number of cells in range that meet the condition defined by criteria. If no cells meet criteria, COUNTIF returns zero. In the example shown, we can use COUNTIF to count the values we are looking for like this

Once the named range data (B5:B16) and cell E5 have been evaluated, we have:

COUNTIF returns 1 because «Blue» occurs in the range B5:B16 once. Next, we use the greater than operator (>) to run a simple test to force a TRUE or FALSE result:

By itself, the formula above will return TRUE or FALSE. The last part of the problem is to return a «Yes» or «No» result. To handle this, we nest the formula above into the IF function like this:

This is the formula shown in the worksheet above. As the formula is copied down, COUNTIF returns a count of the value in column E. If the count is greater than zero, the IF function returns «Yes». If the count is zero, IF returns «No».

Slightly abbreviated

It is possible to shorten this formula slightly and get the same result like this:

Here, we have remove the «>0» test. Instead, we simply return the count to IF as the logical_test. This works because Excel will treat any non-zero number as TRUE when the number is evaluated as a Boolean.

Testing for a partial match

To test a range to see if it contains a substring (a partial match), you can add a wildcard to the formula. For example, if you have a value to look for in cell C1, and you want to check the range A1:A100 for partial matches, you can configure COUNTIF to look for the value in C1 anywhere in a cell by concatenating asterisks on both sides:

The asterisk (*) is a wildcard for one or more characters. By concatenating asterisks before and after the value in C1, the formula will count the text in C1 anywhere it appears in each cell of the range. To return «Yes» or «No», nest the formula inside the IF function as above.

An alternative formula using MATCH

As an alternative, you can use a formula that uses the MATCH function with the ISNUMBER function instead of COUNTIF:

The MATCH function returns the position of a match (as a number) if found, and #N/A if not found. By wrapping MATCH inside ISNUMBER, the final result will be TRUE when MATCH finds a match and FALSE when MATCH returns #N/A.

Источник

How do I use a nested IF(AND) in an Excel array formula?

How do I get a nested ‘AND’ to work inside ‘IF’ in an array formula?

I reduced my problem to the following example: Note: the above image has been updated to included the array formula curly braces

At the top right, we have the search criteria in L3 («color») and L4 («shape»). At the left, column D contains working match formulas for both color and shape in the list of items. The first table shows the match formula working properly without using an array formula.

The second table shows an array formula that matches the color.

The third table shows an array formula that matches the shape.

On the right is my attempt to use both criteria in an array formula, by combining them with AND.

IF the value in the color column matches the color criteria (L3) and the value in the shape column matches the shape criteria (L4), then I want to see «MATCH!».

I did find a workaround: concatenate the values and criteria, and then match them inside a single IF. I feel like there should be a Better Way. like if AND worked as expected!

Note: Many of the answers below work correctly but not as array formulas, which is specifically what this question is about. I looked at my original question and realized I forgot to show the curly braces in the array formula examples. I have fixed the image to show them. Sorry for the confusion.

The key to answering these questions is to write something that works as an array formula, which is entered by pressing CTRL+SHIFT+ENTER after typing the formula into a cell. Excel will automaically add the curly braces to indicate that it’s an array formula.

Источник

Excel — Find a value in an array and return the contents of the corresponding column

I am trying to find a value within an array and then return the value in a specific row in the corresponding column.

In the example below, I need to know which bay the Chevrolet is in:

I am looking for Chevrolet in the array C2:E5. Once it determines that the Chevrolet is in Column D, I need for it to return the value in D1. If it was in column E, I need it to return the value in E1.

Any help would be greatly appreciated. Thank you so much in advance.

4 Answers 4

Try this Array Formula:

or if you are sure that each column contains exactly what’s being searched it can be written like this:

Enter formula in any cell by pressing Ctrl + Shitf + Enter .

How does it work?
Our ultimate goal is to find the Column that contains the match:

  • First we did the search for the match using this formula: SEARCH(A1,$C$1:$E$5) . It just checks if any of the entries matched A1. Actually, it can be simplified to $C$1:$E$5=A1 but I’m not sure if all entries in each column match exactly what’s in A1.
  • That formula will produce an array of values when entered as array formula. Something like: . The result will be array of number(s) and error (if non was found). But we don’t want that, else we will be returning error everytime.
  • We then use IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99) . This formula returns the Column Number if there is a match and a relatively huge number 99^99 otherwise. Result would be: <99^99, 99^99, 99^99, 2, . 99^99>.
  • And we are close to what we need since we already have an array of Column and huge number. We just use SMALL to return the smallest number which in my opinion is the lowest Column Number where a match is found. So SMALL(IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99),1) would return 2. Which is the column where Chevrolet is referenced at $C$1:$E$1.
  • Since we already have the column number we simply use INDEX Function which is: INDEX($C$1:$E$5,1,2) .

Note: 99^99 can be any relatively large number. Not necessarily 99^99 . Actual 16385(max column number in Excel 2007 and up + 1) can be used.

Result:

Источник

Excel if found in array

This article demonstrates several ways to check if a cell contains any value based on a list. The first example shows how to check if any of the values in the list is in the cell.

The remaining examples show formulas that also return the matching values. You may need different formulas based on the Excel version you are using.

Read this article If cell equals value from list to match the entire cell to any value from a list. To match a single cell to a single value read this: If cell contains text

To check if a cell contains all values in the list read this: If cell contains multiple values

What’s on this page

1. Check if the cell contains any value in the list

The image above shows an array formula in cell C3 that checks if cell B3 contains at least one of the values in List (E3:E7), it returns «Yes» if any of the values are found in column B and returns nothing if the cell contains none of the values.

For example, cell B3 contains XBF which is found in cell E7. Cell B4 contains text ZDS found in cell E6. Cell C5 contains no values in the list.

You need to enter this formula as an array formula if you are not an Excel 365 subscriber. There is another formula below that doesn’t need to be entered as an array formula, however, it is slightly larger and more complicated.

  1. Type formula in cell C3.
  2. Press and hold CTRL + SHIFT simultaneously.
  3. Press Enter once.
  4. Release all keys.

Excel adds curly brackets to the formula automatically if you successfully entered the array formula. Don’t enter the curly brackets yourself.

1.1 Explaining formula in cell C3

Step 1 — Check if the cell contains any of the values in the list

The COUNTIF function lets you count cells based on a condition, however, it also allows you to count cells based on multiple conditions if you use a cell range instead of a cell.

The criteria argument utilizes a beginning and ending asterisk in order to match a text string and not the entire cell value, asterisks are one of two wildcard characters that you are allowed to use.

The ampersands concatenate the asterisks to cell range E3:E7.

and returns this array

which tells us that the last value in the list is found in cell B3.

Step 2 — Return TRUE if at least one value is 1

The OR function returns TRUE if at least one of the values in the array is TRUE, the numerical equivalent to TRUE is 1.

Step 3 — Return Yes or nothing

The IF function then returns «Yes» if the logical test evaluates to TRUE and nothing if the logical test returns FALSE.

returns «Yes» in cell B3.

Regular formula

The following formula is quite similar to the formula above except that it is a regular formula and it has an additional INDEX function.

Get the Excel file

2. Display matches if the cell contains text from a list

The image above demonstrates a formula that checks if a cell contains a value in the list and then returns that value. If multiple values match then all matching values in the list are displayed.

For example, cell B3 contains «ZDS, YNO, XBF» and cell range E3:E7 has two values that match, «ZDS» and «XBF».

Formula in cell C3:

The TEXTJOIN function is available for Office 2019 and Office 365 subscribers. You will get a #NAME error if your Excel version is missing this function. Office 2019 users may need to enter this formula as an array formula.

The next formula works with most Excel versions.

Array formula in cell C3:

However, it only returns the first match. There is another formula below that returns all matching values, check it out.

2.1 Explaining formula in cell C3

Step 1 — Count cells containing text strings

The COUNTIF function lets you count cells based on a condition, we are going to use multiple conditions. I am going to use asterisks to make the COUNTIF function check for a partial match.

The asterisk is one of two wild card characters that you can use, it matches 0 (zero) to any number of any characters.

This array contains as many values as there values in the list, the position of each value in the array matches the position of the value in the list. This means that we can tell from the array that the first value and the last value is found in cell B3.

Step 2 — Return the actual value

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(logical_test, [value_if_true], [value_if_false])

This allows us to create an array containing values that exists in cell B3.

Step 3 — Concatenate values in array

The TEXTJOIN function allows you to combine text strings from multiple cell ranges and also use delimiting characters if you want.

TEXTJOIN(«, «, TRUE, IF(COUNTIF(B3, «*»&$E$3:$E$7&»*»), $E$3:$E$7, «»))

and returns text strings ZDS, XBF.

3. Display matches if cell contains text from a list (Earlier Excel versions)

The image above demonstrates a formula that returns multiple matches if the cell contains values from a list. This array formula works with most Excel versions.

Array formula in cell C3:

Copy cell C3 and paste to cell range C3:E15.

3.1 Explaining formula in cell C3

Step 1 — Identify matching values in cell

The COUNTIF function lets you count cells based on a condition, we are going to use a cell range instead. This will return an array of values.

Step 2 — Calculate relative positions of matching values

The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.

IF(logical_test, [value_if_true], [value_if_false])

This allows us to create an array containing values representing row numbers.

I am going to use the SMALL function to be able to extract one value in each cell in the next step.

SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1)))

The COLUMNS function calculates the number of columns in a cell range, however, the cell reference in our formula grows when you copy the cell and paste to adjacent cells to the right.

Step 4 — Return value based on row number

The INDEX function returns a value from a cell range or array, you specify which value based on a row and column number. Both the [row_num] and [column_num] are optional.

INDEX($G$3:$G$7, SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1)))

and returns «ZDS» in cell C3.

Step 5 — Remove error values

The IFERROR function lets you catch most errors in Excel formulas except #SPILL! errors. Be careful when using the IFERROR function, it may make it much harder spotting formula errors.

There are two arguments in the IFERROR function. The value argument is returned if it is not evaluating to an error. The value_if_error argument is returned if the value argument returns an error.

IFERROR(INDEX($G$3:$G$7, SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1))), «»)

4. Filter delimited values not in the list (Excel 365)

The formula in cell C3 lists values in cell B3 that are not in the List specified in cell range E3:E7. The formula returns #CALC! error if all values are in the list, see cell C14 as an example.

Excel 365 dynamic array formula in cell C3:

4.1 Explaining formula

Step 1 — Split values with a delimiting character

The TEXTSPLIT function splits a string into an array based on delimiting values.

Function syntax: TEXTSPLIT(Input_Text, col_delimiter, [row_delimiter], [Ignore_Empty])

TEXTSPLIT(«ZDS, VTO, XBF»,,»,»)

Step 2 — Remove leading and trailing spaces

The TRIM function deletes all blanks or space characters except single blanks between words in a cell value.

Function syntax: TRIM(text)

Step 3 — Check if values are in list

The COUNTIF function calculates the number of cells that is equal to a condition.

Function syntax: COUNTIF(range, criteria)

These numbers indicate if a value is found in the list, zero means not in the list and 1 or higher means that the value is in the list at least once.

The number’s position corresponds to the position of the values. <1; 0; 1>— <«ZDS»; «VTO»; «XBF»>meaning «ZDS» and «XBF» are in the list and «VTO» not.

Step 4 — Not

The NOT function returns the boolean opposite to the given argument.

Function syntax: NOT(logical)

0 (zero) is equivalent to FALSE. The boolean opposite is TRUE.

Any other number than 0 (zero) is equivalent to TRUE. The boolean opposite is FALSE.

Step 5 — Filter

The FILTER function extracts values/rows based on a condition or criteria.

Function syntax: FILTER(array, include, [if_empty])

Step 6 — Join

The TEXTJOIN function combines text strings from multiple cell ranges.

Function syntax: TEXTJOIN(delimiter, ignore_empty, text1, [text2], . )

Step 7 — Shorten the formula

The LET function lets you name intermediate calculation results which can shorten formulas considerably and improve performance.

Function syntax: LET(name1, name_value1, calculation_or_name2, [name_value2, calculation_or_name3. ])

Logic category

Functions in this article

Excel formula categories

Excel categories

48 Responses to “If cell contains text from list”

Great post, very helpful. thanks.

How would you show the actual match rather than just «Yes»?

Array formula in cell C3:
=TEXTJOIN(«, «, TRUE, IF(COUNTIF(B3, «*»&$E$3:$E$7&»*»), $E$3:$E$7, «»))

If Cell contains A B C then how to show in One one column .

The post is helpful!

I tried the array formula to return the actual match but it didn’t work for me. I selected C3:C15, copied the formula in the comment section and pressed ctrl+shift+enter but all the cells reflected the array formula <=TEXTJOIN(«, «, TRUE, IF(COUNTIF(B3, «*»&$E$3:$E$7&»*»), $E$3:$E$7, «»))>.

May I know if I did something wrong?

Did you enter the curly brackets? If you did, don’t. They appear automatically to confirm that you successfully entered an array formula.

Thanks alot for posting this. It has really sorted me out. I will shine like a super star. I owe you tons! be blessed!

Great Help!! Oscar.. Thank you very much!!

array formula works for me perfectly well, but my file has a lot of data, around 2000 rows and excel results in hung due to lot of processing.
is there any way to make it more quicker; as this file has many formulas apart from the one that you have mentioned and that worked for me.

appreciate if you can assist further.

I want it to only return the value if it finds exact match. For example if my list contains black cat, white cat because it contains the word cat it is bringing it up.
Can you help?

I am also experiencing this issue

Thank you for article. It helped me to automate an excel file and save a lot of time! Is it possible to return all the values from a list instead of just one.

For eg: If in list A, i have ABC,DEF,GHI and in list B I have ABC and DEF. I want it to return both ABC and DEF values for list A. Right now it is only returning one value that is ABC (the first value in the list B) instead of both (ABC and DEF).

If it helps the formula I am using is

=IFERROR(INDEX(abc_l, SMALL(IF(COUNTIF($E153, «*»&abc_l&»*»), MATCH(ROW(abc_l), ROW(abc_l)), «»), COLUMNS($A$1:A152))), «»)

Thank you again for the article!

Thanks for this very useful formula. I know a lot of what Excel can do, just not how to make it do it.
I’m using the formula
=TEXTJOIN(«, «, TRUE, IF(COUNTIF(B3, «*»&$E$3:$E$7&»*»), $E$3:$E$7, «»))

Thank you so much!

I cannot see any of the «images» where you say, «the image above.» I think that would really help me to follow along.

I’ve tried multiple browsers and machines.

I am specifically looking at the formula for Previous Versions to return a match. I think seeing the example would really help me follow, as I haven’t gotten it down yet. Thank you!

=IFERROR(INDEX($G$3:$G$7, SMALL(IF(COUNTIF($B3, «*»&$G$3:$G$7&»*»), MATCH(ROW($G$3:$G$7), ROW($G$3:$G$7)), «»), COLUMNS($A$1:A1))), «»)

Thanks so much for this but I’ve gotten into knots trying to modify a working formula
=IFERROR(INDEX(OfferDetails[#Data],SMALL(IF(OfferDetails[OC ‘#]=rngOC,ROW(OfferDetails[#Data])-ROW(OfferDetails[#Headers])), ROW(2:2)), MATCH($C$14, OfferDetails[#Headers], 0)),»»)
with
=IFERROR(INDEX(OfferDetails[#Data],SMALL(IF(OR(COUNTIF(OfferDetails[OC ‘#],»*»&rngOC&»*»))=rngOC,ROW(OfferDetails[#Data])-ROW(OfferDetails[#Headers])), ROW(1:1)), MATCH($C$14, OfferDetails[#Headers], 0)),»»)

My column OfferDetails[OC ‘#] earlier had just one record example — 685-cf-18A . Now it has three 685-cf-18A ,685-cf-24b, 685-cf-11c .
I need to be able to match one of these three to rngOC.

Simply cannot figure out what is going wrong . Any suggestions I could try please ?
Anandi

I have this formula in a spreadsheet. It used to work, but now it does not. Are you aware of updates that would make it stop working?

where colors is a defined range of cells on another tab in the spreadsheet

Strangely, in a list of about 2000 names of which many should return a «yes», I get exactly one «yes», and I can’t figure out what’s special about that one. For example, the word that hits isn’t the first one in the list of things I’m looking for or anything like that.

Seems worth noting that using the SEARCH formula, I am able to get the names that I would expect to hit against my list to do so. For example, for «White-tailed eagle», Excel agrees that the word «white» is in the cell, if I check only against the cell that has «white» in it. It’s just a problem of searching against a list.

This was super helpful and works for me at identifying key words in a list of book titles. Is there a way to search multiple fields at once? (e.g., Find any word (from the array) in cells B3, L3, or Q3)

Thank you. This is very helpful. I was wondering if there was a way to display one specific word when a word from a list is found?
For example,
I have 5 lists (A,B,C,D,E) and in each list there are a set of specific words unique to just that list. How could I have it check each cell and display the List Name when the cell contains a word from that list?
In my situation there will «not» be multiple words in the search cell that are in the lists. Each cell will only contain one word from the 5 lists. Thanks for your time!

Formula in cell I3:

Hello .. I am looking for this answer as well .. is there a operator that could make it so that only an exact match of the row is returned? similar to this question

I want it to only return the value if it finds exact match. For example if my list contains black- cat, white-cat because it contains the word cat it is bringing it up.
Can you help?

I am curious of the same thing. I am currently using the formula above but need to have an exact match instead of a partial word match. Any help on this?

Thanks for your post! I am not an Office 365 subscriber and I have attempted the version of the formula that doesn’t use the TEXTJOIN function but it isn’t working, and I entered the formula as an array formula.
[IFERROR(INDEX($G$2:$G$60, SMALL(IF(COUNTIF($B2, «*»&$G$2:$G$60&»*»), MATCH(ROW($G$2:$G$60), ROW($G$2:$G$60)), «»), COLUMNS($A$1:A1))), «»)]

Upon digging, I discovered that it isn’t working because this portion of the formula COUNTIF($B2, «*»&$G$2:$G$60&»*»)is returning only the value of the first cell in my range. I’m unsure of what I’m doing wrong, and I have checked multiple times to ensure I have entered the formula as an array. Using Excel 2016. Please do you have any recommendations? Thank you!

the array formula returns one value per cell, did you copy the cell and paste to adjacent cells to the right as well?

I’ve used the formula =INDEX($E$3:$E$7, MATCH(1, COUNTIF(B3, «*»&$E$3:$E$7&»*»), 0))
However, it searches from left to right.
For examples: in cell B3 value is «MVN, YNO, XBF»
after applying the formula (=INDEX($E$3:$E$7, MATCH(1, COUNTIF(B3, «*»&$E$3:$E$7&»*»), 0))) I am getting result as «MVN».

I want the last value (that mean it should search from right instead of left).

The reason to get this type of result is there are multiple agents in particular conversation, and I in my cell value the latest agents will be at last and that is what I want).

Here is the screen shot

try this:
=INDEX($E$3:$E$7, MATCH(2, COUNTIF(B3, «*»&$E$3:$E$7&»*»), 1))

Nope it is not working.

please disregard this. Let me check again.

I’ve checked it is not working, it is only working when there are only 2 or 3 values in the cell, ,, if there are multiple for examples 5 or 6 it is not working.

It seems to be working here, can you post a screenshot when it is not working?

I’ve tried it is not working. It is just working for the first cell after that if you drag it down it doesn’t work.

here is the google link where I’ve uploaded excel file, please have a look.

you are right. It doesn’t work.
Try this array formula:
=INDEX($E$3:$E$7, MATCH(2, 1/COUNTIF(B3, «*»&$E$3:$E$7&»*»)))

It’s working. Thank you very much.

You won’t believe I was working on this from a long time and somehow I landed on this website where finally it is fixed. By the way, I have to most of my work on excel to prepare reports, work on raw data and compile files, so your formulas and other stuff helped me a lot.

Hi! This formula sorted my issue out!
=INDEX($E$3:$E$7, MATCH(1, COUNTIF(B3, «*»&$E$3:$E$7&»*»), 0))

Thank you so much! I spent countless hours trying to figure this out. you are a lifesaver!!

If a cell contains a value from a list I want it to return a value from an adjacent list
If anyone can help, I’d really appreciate it.

Seems the above formulas are very close to it but I can’t seem to get it to work

I need help in similar lines. I have a text that will be a part of a array, There will be other text as well in that cell that has this text in the array, I want to find that text in the array and return the values in that cell

How it work with cell D3 in last case, when we just take small value from array for index function?
it’s mean how take next value in array if have more values match.

Please give me your idea/advice.
Thank you very much.

I tried this and it didn’t work for me. All the results show as zeroes. And yes, I did the CTRL-SHIFT-ENTER to add the braces with no change. I am using Excel 2016.

Make sure you check the cell references, and that you enter the formula in one cell and then copy the cell and paste to cells below.

I have about 2 thousand records to check and list as long as 155 values in a column. So, I modified and tried this but it didn’t work for me. All the results show as zeroes. And yes, I did the CTRL-SHIFT-ENTER to add the braces with no change. I am using Excel 2016.

All the results show as zeroes.
Your result is weird, the IF function returns either «Yes» or nothing «», not zeros. Use the «Evaluate Formula» tool to see what is wrong.

Cell reference B3 points to the first cell in your list of about 2000 records.

$E$3:$E$7 references your list containing 155 values. Make sure you use $ to make the cell references absolute (locked).

Hi Oscar, GREAT work!

I got your «2. Display matches if the cell contains text from a list» working nicely in Excel 365 (textjoin is functional).

Thing is, what I REALLY need is to list all those values that are NOT in the reference LIST. I tried using the boolean NOT, but I can’t make it work.

In your example above, I would need:

Description Category List
————- ————- ——
ZDS, YNO, XBF YNO MVN
CAU, ZDS, XXS CAU, XXS QLL
NQM, BJC, UND NQM, BJC, UND BQX
BQX, USE, HGO USE, NGO ZDS
MXH, YGO, EZO MXH, YGO, EZO XBF

I tried brute force: first getting the existing values in one cell (as you show) and then trying to extract the differing values, but couldn’t.

Could you illuminate me on what the elegant process be for this need?

btw: I had the same issue as others commented here. I was getting a hit for both «act» and «actually» when I only wanted «act». I solved it via brute force, changing both the items and the list into «[act]» and [actually] so the search was exact. It’s working, so don’t worry about this.

Great question, I have added another section to this article that I think answers your question: Filter delimited values not in list (Excel 365)

I’ll look at your new article and comment ASAP

Источник

Look up values in a list of data

Excel for Microsoft 365 Excel for the web Excel 2021 Excel 2019 Excel 2016 Excel 2013 Excel 2010 Excel 2007 More…Less

Let’s say that you want to look up an employee’s phone extension by using their badge number, or the correct rate of a commission for a sales amount. You look up data to quickly and efficiently find specific data in a list and to automatically verify that you are using correct data. After you look up the data, you can perform calculations or display results with the values returned. There are several ways to look up values in a list of data and to display the results.

What do you want to do?

  • Look up values vertically in a list by using an exact match

  • Look up values vertically in a list by using an approximate match

  • Look up values vertically in a list of unknown size by using an exact match

  • Look up values horizontally in a list by using an exact match

  • Look up values horizontally in a list by using an approximate match

  • Create a lookup formula with the Lookup Wizard (Excel 2007 only)

Look up values vertically in a list by using an exact match

To do this task, you can use the VLOOKUP function, or a combination of the INDEX and MATCH functions.

VLOOKUP examples

=VLOOKUP (B3,B2:E7,2,FALSE)

VLOOKUP looks for Fontana in the first column (column B) in the table_array B2:E7, and returns Olivier from the second column (column C) of the table_array.  False returns an exact match.

=VLOOKUP (102,A2:C7,2,FALSE)

VLOOKUP looks for an exact match (FALSE) of the last name for 102 (lookup_value) in the second column (column B) in the A2:C7 range, and returns Fontana.

For more information, see VLOOKUP function.

INDEX and MATCH examples

INDEX and MATCH functions can be used as a replacement to VLOOKUP

In simple English it means:

=INDEX(I want the return value from C2:C10, that will MATCH(Kale, which is somewhere in the B2:B10 array, where the return value is the first value corresponding to Kale))

The formula looks for the first value in C2:C10 that corresponds to Kale (in B7) and returns the value in C7 (100), which is the first value that matches Kale.

For more information, see INDEX function and MATCH function.

Top of Page

Look up values vertically in a list by using an approximate match

To do this, use the VLOOKUP function.

Important:  Make sure the values in the first row have been sorted in an ascending order.

An example of VLOOKUP formula looking for an approximate match

In the above example, VLOOKUP looks for the first name of the student who has 6 tardies in the A2:B7 range. There is no entry for 6 tardies in the table, so VLOOKUP looks for the next highest match lower than 6, and finds the value 5, associated to the first name Dave, and thus returns Dave.

For more information, see VLOOKUP function.

Top of Page

Look up values vertically in a list of unknown size by using an exact match

To do this task, use the OFFSET and MATCH functions.

Note: Use this approach when your data is in an external data range that you refresh each day. You know the price is in column B, but you don’t know how many rows of data the server will return, and the first column isn’t sorted alphabetically.

An example of OFFSET and MATCH functions

C1 is the upper left cells of the range (also called the starting cell).

MATCH(«Oranges»,C2:C7,0) looks for Oranges in the C2:C7 range. You should not include the starting cell in the range.

1 is the number of columns to the right of the starting cell where the return value should be from. In our example, the return value is from column D, Sales.

Top of Page

Look up values horizontally in a list by using an exact match

To do this task, use the HLOOKUP function. See an example below:

An example of HLOOKUP formula looking for an exact match

HLOOKUP looks up the Sales column, and returns the value from row 5 in the specified range.

For more information, see HLOOKUP function.

Top of Page

Look up values horizontally in a list by using an approximate match

To do this task, use the HLOOKUP function.

Important:  Make sure the values in the first row have been sorted in an ascending order.

An example of HLOOKUP formula looking for an approximate match

In the above example, HLOOKUP looks for the value 11000 in row 3 in the specified range. It does not find 11000 and hence looks for the next largest value less than 1100 and returns 10543.

For more information, see HLOOKUP function.

Top of Page

Create a lookup formula with the Lookup Wizard (Excel 2007 only)

Note: The Lookup Wizard add-in was discontinued in Excel 2010. This functionality has been replaced by the function wizard and the available Lookup and reference functions (reference).

In Excel 2007, the Lookup Wizard creates the lookup formula based on a worksheet data that has row and column labels. The Lookup Wizard helps you find other values in a row when you know the value in one column, and vice versa. The Lookup Wizard uses INDEX and MATCH in the formulas that it creates.

  1. Click a cell in the range.

  2. On the Formulas tab, in the Solutions group, click Lookup.

  3. If the Lookup command is not available, then you need to load the Lookup Wizard add-in program.

    How to load the Lookup Wizard Add-in program

  4. Click the Microsoft Office Button Office button image, click Excel Options, and then click the Add-ins category.

  5. In the Manage box, click Excel Add-ins, and then click Go.

  6. In the Add-Ins available dialog box, select the check box next to Lookup Wizard, and then click OK.

  7. Follow the instructions in the wizard.

Top of Page

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Понравилась статья? Поделить с друзьями:
  • If formulas in word tables
  • If and or syntax in excel
  • If formula with color in excel
  • If and or functions in excel 2007
  • If and or function in excel with example