Formula to calculate if 0 - excel

See the following image:
In cell B5 I have =(AND(IF(B2=0,SUM(2+2),0),IF(B3="",SUM(2+2),0))) and it is saying TRUE, instead of calculating and giving me 4. I don't know why.
What I want is, if I enter 0 for Apple in cell B2 and leave cell B3 for Orange blank (must be blank or an error will appear), only then I want cell B5 to calculate 2+2=4. Now, if I enter 0 for Orange in cell B3 and leave cell B2 for Apple blank (must be blank or an error will appear), then I want cell B5 to have a value of 0.

Change to:
=IF(AND(B2=0, B3=""), SUM(2,2),0)
So, in your case, you will be looking to input:
=IF(AND(B2 = "", B3 = ""), "Error", IF(AND(B2=0, B3=""), (1+(K17*4))*K31),0))
Originally, you were not returning a sum, you were returning a boolean (TRUE or FALSE) from the =AND() statement. Since =AND() was on the outside, you were not returning what you wanted. If you want to return a value, you must use the =IF() statement in Excel. Also, you do not need to do =SUM(2+2), you can just calculate 2+2. Furthermore, you do not need to calculate =SUM(1+(K17*4))*K31) because all of your elementary operations are taken care of in your formula inside the =SUM() function.

Using the below function works;
=IF(AND(B2=0;B3="");SUM(2+2);IF(AND(B2="";B3=0);0;"Error Message"))
In this case, if B2 is 0, and B3 is blank, you'll get your formula (SUM(2+2)).
If B2 is blank, and B3 = 0, you'll get value 0.
In all other cases (e.g. Both blank), you will get the error message.

Related

Populate Cell with standard wording when another cell returns anything other than zero

I am currently trying to work out how to populate a cell when the result in another cell is above or below zero.
I.e. If cell A1 returns a result greater than or less than zero I would like cell B2 to return the wording <<<<<< Error - Cell must equal zero.
Not sure if it helps but the figure in cell A1 is produced as a result of the difference between two other cells. E.g. formula in cell A1 is D2 - D5.
Disclaimer: Pretty much a complete novice with VBA. Experience includes about 6 If/Elseif statements.
You don't need VBA to achieve the desired output.
Place the following formula in B1 ( if you want to display the error msg in B1 depending upon the output returned by the formula in A1)
=A1
And then apply the following custom formatting to the B1.
"<<<<<< Error - Cell must equal zero.";"<<<<<< Error - Cell must equal zero.";
This will produce the following output in B1.

Making the criteria of DMIN and DMAX depend on the value specified in a given cell

I'm trying to find a way to dynamically adust the criteria used in calls to db functions like DMAX and DMIN by specifying the criterion value to be obtained from anotheer cell in the worksheet. To illustrate what I mean, please try this:
Start with a blank Excel 2007 worksheet.
Enter the word Test in cells A1, D1 and A7 and the numbers 1,2 and 3 into cells A8, A9 & A10 respectively.
Enter >=3 in A2 and =">=a5" in D2
Click cell A4 and enter the following into the formula box:=DMIN(A$7:A$10, 1, A$1:A$2).
A4 now correctly displays the value 3. However, what I'd like to know is the correct criteria expression to say that it should pick up the value to use from another cell.
So
Enter 2 in A5.
Enter =DMIN(A$7:A$10, 1, D$1:D$2) in A6.
A6 now displays 0, which is not what I want. I want the value to be used in the criterion to be picked up from A5. So, my question is, what is the correct way to tell the criterion to get the expression value from the contents of another cell?
=">=a5" will return the string >=a5 when you want it to return the result of the cell not the cell address.
Remove the cell address from the quotes:
=">=" & A5
This now will return >= and the value in A5, in this case 2; >=2.
This then can be properly interpreted by the DMIN.

Excel with negative numbers

I would like to put in a number as a total, say B2. Then put in a negative number under it in B3, and subtract B3 form B2 and B2 shows the total. If i put in 10 in B2 and -5 in B3 and then B2 would show 5.
This would be an example of circular reference and therefore not possible. The result of the calling cell depends on the value of the referenced cell which depends on the value of the calling cell. It can never come to a resolution.
You can instead do one of two options. Change B2 into a formula:
=10+B3
This way B2 will show the value 5 by adding the negative -5 from B3 to 10.
Else, if you need it to be more dynamic, then add the 10 value to some other cell. For instance:
B1: 10, B2: =B1+B3, B3: -5
With the above B2 will show the value 5. You can then later change the B1 and/or B3 values to manipulate B2. For instance, if you change B1 to 5, and B3 remains the same, then B2 will show 0.

Return text within the same cell if value is less than zero

Is it possible to return a text value within the same cell if a cells formula result is less than zero..
I have a formula =A2+B2, if the result is positive then display result , if negative then "No Bonus" ..
Yes, just use an If() formula.
Say the cell with the formula =A2+B2 is C1, you can do this:
=If(C1>=0,C1,"No Bonus")
Or without the C1 cell: =If((A2+B2)>=0,A2+B2,"No Bonus")
Note that if the employee gets 0, that's included as a "positive".

If 1 or 2 cells are blank then

I'm trying to write a simple formula to check whether either 1 or both cells are blank and, if so, leave the resulting cell blank. I want the resulting cell to only display a calculation if both cells are filled in.
I've got this do far though it doesn't work as I wanted: =IF(OR(C4<>"",B4<>""),A4-C4,"")
b4 has a date and c4 has a numeric value (4). the formulate is in d4. I want to check if b4 or c4 are blank and, if so, leave d4 blank too, else take c4 from a4 (14 as of now).
It should work:
=IF(ISBLANK(C4);"";IF(ISBLANK(D4);"";A4-C4))
It checks if C4 is a blank cell, if not then checks if D4 is blank, if not then does the math.
I recommend using ISBLANK to check for blank cells.
Formula for your D4:
=IF(OR(ISBLANK(B4), ISBLANK(C4)),,A4-C4)
Just try this formula
=IF(AND(C4<>"",B4<>""),A4-C4,"")
Also, I used =IF(A2&B2="",TRUE VALUE, FALSE VALUE) which worked great

Resources