Avatar of BlosMusic
BlosMusic

asked on 

AND nested with OR gives wrong answer

I have many problems at the moment with IF statements. Why is it that sometimes (see attached sample) I just get the text I entered in the formula box and not the formula working as it should? That's my first question. There will be others if I don't give up beforehand with Excel's weirdness. See attached example.
EE-sample.xlsx
Microsoft Excel

Avatar of undefined
Last Comment
BlosMusic
Avatar of Joe Howard
Joe Howard
Flag of United States of America image

If the cell format is set to Text, it will show the formula instead of the value. To change this change the cell format to General.
Click on B6 on Sheet1, change the format from Text To General (Home Tab --> Number -->From available formats select General).
Now while B6 is still selected, press F2 (Function Key) and press Enter.
The B6 will show the value returned by the formula, not the formula itself.

Does this help?
The formula in D5 is returning the correct output as per the formula in the cell.
What are you expecting it to return?

As per the current formula, if B4 is Ferrari and B5 is Coloured and B6 is either 832 or 902 S2, the formula will return 1, else it would return 99.
Are you expecting something else?
Avatar of BlosMusic
BlosMusic

ASKER

This doesn't do anything. Please look at my sample, that I have amended, below, and . . . . well, can you see what is wrong? Beats me . . . .
EE-sample.xlsx
Avatar of BlosMusic
BlosMusic

ASKER

Sorry, getting ahead of myself here! I will look at sktneer's suggestion in a moment, but in the meantime (and this is where I was heading), I just get the wrong answer from the formula. I appreciate that this is to with formatting (I suppose), but boy is it frustrating!!
The formula in D5 should be like this.....

=IF(AND(B4="Ferrari",B5="Coloured",OR(B6=832,B6="902 S2")),1,99)

Open in new window


832 is number not text. In your previous formula, you enclosed 832 with double quotes like "832", therefore the formula assumes B6 should be a text 832 not the number 832. And Text 832 and the number 832 are not equal.
Avatar of BlosMusic
BlosMusic

ASKER

You did it! Yeaaaah! That's working. Doh! Sorry if I seem thick. Excel isn't necessarily humanly intuitive. Brilliant it may be, but to a poor old sod like me it's weird on occasions!
Thanks all!
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Please mark your question as Solved by selecting an Acceptable Solution.

Thanks.
Avatar of BlosMusic
BlosMusic

ASKER

So quick, and very helpful . . . .
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo