ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   nested "If statement" using text (https://www.excelbanter.com/excel-worksheet-functions/130903-nested-if-statement-using-text.html)

RonB

nested "If statement" using text
 
This is my expression.

=IF(M1="M",12,IF(M1="SM",24,IF(M1="W",24.2,IF(M1=" BW",26.07,IF(M1="A",1)))))

The result is "False" for the "M","A", and "w". The results for "SM" and
"BW" are correct. (24 and 26.07) is there something wrong with my statement?

Thanks

Ron B

joel

nested "If statement" using text
 
The code works exactly as written.
If I enter the following letters in M1 I get
M 12
SM 24
W 24
BW 26.07

any other input get FALSE because M1="A",1 there is no 2nd parameter

you could write M1="A",1,0

then you would get a 0 for any other response

"RonB" wrote:

This is my expression.

=IF(M1="M",12,IF(M1="SM",24,IF(M1="W",24.2,IF(M1=" BW",26.07,IF(M1="A",1)))))

The result is "False" for the "M","A", and "w". The results for "SM" and
"BW" are correct. (24 and 26.07) is there something wrong with my statement?

Thanks

Ron B


bj

nested "If statement" using text
 
you may have to use the trim() function to get rid of non visable characters.

=IF(trim(M1)="M",12,IF(trim(M1)="SM",24,IF(trim(M1 )="W",24.2,IF(trim(M1)="BW",26.07,IF(trim(M1)="A", 1)))))

or shorter
=vlookup(trim(M1),{"M","SM","W","BW","A";12,24,24. 2,26.07,1},2,0)
"RonB" wrote:

This is my expression.

=IF(M1="M",12,IF(M1="SM",24,IF(M1="W",24.2,IF(M1=" BW",26.07,IF(M1="A",1)))))

The result is "False" for the "M","A", and "w". The results for "SM" and
"BW" are correct. (24 and 26.07) is there something wrong with my statement?

Thanks

Ron B



All times are GMT +1. The time now is 12:08 PM.

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