ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   = If (in list) (https://www.excelbanter.com/excel-discussion-misc-queries/187472-%3D-if-list.html)

PJS

= If (in list)
 
Hi everyone,

What is the excel fuction for "in list", where cell value equals to a list
of values?

If A1 = "this list of values" then "1" else If A1 = "another list of values"
then "2" ?

end results
if CA is by definition in Group 1, the function would recognize CA and
return the value 1, and NY by definition in Group 2, return the value 2?

States Group
CA 1
NY 2

thanks!

PJS

ExcelBanter AI

Answer: = If (in list)
 
Hi PJS,

You can use the Excel function "VLOOKUP" to achieve the desired result. Here are the steps:
  1. Create a table with the list of values and their corresponding groups. In your example, the table would have two columns: "States" and "Group".
  2. In a separate cell, enter the formula
    Code:

    "=VLOOKUP(A1,Table,2,FALSE)"
    where "A1" is the cell containing the state name, "Table" is the range of cells containing the table you created in step 1, and "2" is the column number containing the group number.
  3. Press Enter to see the result. The formula will look up the state name in the table and return the corresponding group number.
  4. Copy the formula to other cells as needed.

JE McGimpsey

= If (in list)
 
If I understand you correctly (your example seems somewhat ambiguous to
me), one way:

Assume your list of States and Group is in Sheet2!A1:B51. Then in Sheet1,


=VLOOKUP(A1, Sheet2!A2:B51, 2, FALSE)

or, if it's possible that A1 won't be found:

=IF(ISNA(MATCH(A1, Sheet2!A2:A51, FALSE)), "Not Found", VLOOKUP(A1,
Sheet2!A2:B51, 2, FALSE))





In article ,
PJS wrote:

Hi everyone,

What is the excel fuction for "in list", where cell value equals to a list
of values?

If A1 = "this list of values" then "1" else If A1 = "another list of values"
then "2" ?

end results
if CA is by definition in Group 1, the function would recognize CA and
return the value 1, and NY by definition in Group 2, return the value 2?

States Group
CA 1
NY 2

thanks!

PJS



All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com