Rectified formula neded

hsandeep

Well-known Member
Joined
Dec 6, 2008
Messages
1,226
Office Version
  1. 2010
Platform
  1. Windows
  2. Mobile
I am using

AFZ53=IF(AND(AFB53<>0,AFB53<$AFO53),-100,IF(AFA53>$AFN53,100,0)) but getting 100 (This is WRONG) I should get 0. What should the rectified formula be?

AFA53=FALSE
AFB53=FALSE
AFN53=2.5
AFO53=-2.5
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
TRUE / FALSE will take precedence over the value it's compared to.
Change the formula to

Code:
=IF(AND(AFB53<>0,AFB53<$AFO53),-100,IF($AFN53>AFA53,100,0))
 
Upvote 0
This may help.....


Example 3. Comparing Boolean values and numbers
There is a widespread opinion that, in Microsoft Excel, the Boolean value of TRUE always equates to 1 and FALSE to 0. However, this is only partially true, and the key word here is "always" or more precisely "not always" : )

When writing an 'equal to' logical expression that compares a Boolean value and a number, you need to specifically point out for Excel that a non-numeric Boolean value should be treated as a number. You can do this by adding the double minus sign in front of a Boolean value or a cell reference, e. g. =A2=--TRUE or =A2=--B2.

The 1st minus sign, which is technically called the unary operator, coerces TRUE/FALSE to -1/0, respectively, and the second unary negates the values turning them into +1 and 0. This will probably be easier to understand looking at the following screenshot:
Comparing Boolean values and numbers
 
Upvote 0
Cannot make a direct comparison of Boolean (True\False) values to Numeric values. One way to convert Boolean to Numeric is to multiply them by 1

AFZ53=IF(AND(AFB53*1<>0,AFB53*1<$AFO53),-100,IF(AFA53*1>$AFN53,100,0))
 
Upvote 0
So does that negate the need for the double unary, as per my previous post ??
 
Upvote 0
But the double-unary is simply one of several mathematical operations which will coerce Boolean values to their numerical equivalents. Multiplication by unity (as used by AlphaFrog), addition of zero and division by unity are three more examples.

It's always slightly surprised me that, of these choices, the double-unary is perhaps the most widely-used, especially given that, of those choices, it is also perhaps the least intuitive.

Regards
 
Upvote 0
Thanks for the input.....always glad to learn from others...:beerchug:
 
Upvote 0
:lol:....why can't you have a beer at 8am....:confused:
 
Upvote 0
Haha! I should've seen that I was talking to an Aussie! :) There's no time that isn't beer time, eh? :laugh:
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top