ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   If statement (https://www.excelbanter.com/excel-worksheet-functions/216208-if-statement.html)

Zack

If statement
 
In cell H4 I want one of three model numbers to appear. Each model number is
assigned a value, so 1112111 will equal HRV019SB1. So the formula for H4 is,
as of now, =IF(H4=1112111,"HRV019SB1"). And that works great if 1112111
appears. How do I write the formula for multiple values, so if 2112111
appears, a different model number will be shown.

Here's my example
1112111=HRV019SB1
2112111=HRH019SB1
1113111=HRV024SB1

JBeaucaire[_85_]

If statement
 
You can stack the IF statements all into one:

=IF(H4=1112111,"HRV019SB1",IF(H4=2112111,"HRH019SB 1",IF(H4=1113111,"HRV024SB1","not found"))).

That works, but you can only go 7 deep that way on Excel 2003. You could
build a lookup table in a formula as long as you remember to keep the numeric
values in ascending order, like so:

=LOOKUP(H4,{1112111,1113111,2112111},{"HRV019SB1", "HRV024SB1","HRH019SB1"})
--
"Actually, I AM a rocket scientist." -- JB


"Zack" wrote:

In cell H4 I want one of three model numbers to appear. Each model number is
assigned a value, so 1112111 will equal HRV019SB1. So the formula for H4 is,
as of now, =IF(H4=1112111,"HRV019SB1"). And that works great if 1112111
appears. How do I write the formula for multiple values, so if 2112111
appears, a different model number will be shown.

Here's my example
1112111=HRV019SB1
2112111=HRH019SB1
1113111=HRV024SB1



All times are GMT +1. The time now is 11:15 PM.

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