简体   繁体   中英

Produce a value in one cell, if another cell contains a specific text in Excel

I have an excel file that has 1000 rows. I would like to insert certain values in a specific column if another column contains a certain text string.

name    value
hello
ok
sure
hello

在此处输入图像描述

Where ever there is the word, hello, I would like 33 for ok, I'd like 32 for sure, I'd like 34

Doing:

=IF(B5=$B$4,33,"")

This works, but how would I include the other criteria? The formula keeps saying I have too many arguments.

在此处输入图像描述

Any suggestion is appreciated.

If your value is assigned liked hello=33 , ok=32 , sure=34 then you can use below formula.

=INDEX({33,32,34},,MATCH(A2,{"hello","ok","sure"},0))

With Excel365 you can use XLOOKUP()

=XLOOKUP(A2,{"hello","ok","sure"},{33,32,34})

在此处输入图像描述

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