Conditional Result in Excel

Abdullah_h

New Member
Joined
Nov 6, 2018
Messages
7
Hello guys

I need your help to write the correct formula. I will explain my concern in a simplified example:

CELL | Value

A1 | 500
A2 | =if(A1>100, "Error: Too High", "")
A3 | =if(A1<0, "Error: Too Low", "")


I need to write a formula in B1 that returns A1 only if A2 and A3 are both false. If any of A2:A3 is true, then return its value. In the aforementioned example, the B1 result should be "Error: Too High".

If we change the number in A1 to 99. B1 should show 99.

If I add another condition in A4 as follows: =if(A1<-10, "Error: Extremely Low",""). And add a number -11 in A1, how to show both errors in B1.

I hope my explanation is clear.

Thank you
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Re: Need Help - Conditional Result in Excel

try

=if(A1<-10,"Error: Extremely Low",if(A1<0,"Error: Too Low",if(A1>100, "Error: Too High",A1)))
 
Upvote 0
Re: Need Help - Conditional Result in Excel

This would only help for a simple example. However, it is needed actually for a very long list of errors with very long formulas & it would be too difficult to combine all in one. I am thinking of using VLOOKUP function but could not write it correctly.

Hint: if this would help, all conditions include the text "Error".
 
Upvote 0
Re: Need Help - Conditional Result in Excel

try this, you can extend the vlookup table in Cols D:E as needed


Book1
ABCDE
1Error: Too Low-5-100Error: Extremely Low
2-10Error: Too Low
30OK
4100Error: Too High
5500Error: Too Too High
Sheet2
Cell Formulas
RangeFormula
A1=IF(VLOOKUP(B1,D1:E5,2)="OK",B1,VLOOKUP(B1,D1:E5,2))
 
Upvote 0
Re: Need Help - Conditional Result in Excel

Thanks Alan. However, I could not apply your formula :eek:

Allow me share with you another example. Hopefully you understand my concern better. How would you write the formula here in F16 that should return H11 unless if one of the exemptions apply (then it should show the error instead of H11). Please have a look at the uploaded picture (unfortunately I could not insert the pic in the post
0IMGJZU
).

https://imgur.com/a/0IMGJZU

Thank you in advance,
 
Upvote 0
Re: Need Help - Conditional Result in Excel

A
B
C
D
1
XY Company
Date
2
3
Client Name
Location
4
5
Delivery Date
Valuation
6
7
Total Price

<tbody>
</tbody>

Cell B7 should combine all these formulas:
=if(D1>B5, "Error: Purchase Date must be on/before Delivery Date", D5)
=if(D3="New York","Error: Location is not covered", D5)
=if(D5<0, "Error: Price is invalid", D5)
=if(B3="","Error: Client Name is missing", D5)

--------------------------------------------------

I tried to use the forum embedded tool to create the above table. I hope the idea I am trying to explain is now clear.

Thanks
 
Upvote 0
Re: Need Help - Conditional Result in Excel

that should cover them, you might wanted to tidy up the format

Code:
=IF(OR(D1>B5,D3="New York",D5<=0,B3=""),IF(D1>B5, "Error: Purchase Date must be on/before Delivery Date", " ")&IF(D3="New York","Error: Location is not covered", " ")&IF(D5<=0, "Error: Price is invalid", " ")&IF(B3="","Error: Client Name is missing", " "),D5)
 
Upvote 0
Re: Need Help - Conditional Result in Excel

that should cover them, you might wanted to tidy up the format

Code:
=IF(OR(D1>B5,D3="New York",D5<=0,B3=""),IF(D1>B5, "Error: Purchase Date must be on/before Delivery Date", " ")&IF(D3="New York","Error: Location is not covered", " ")&IF(D5<=0, "Error: Price is invalid", " ")&IF(B3="","Error: Client Name is missing", " "),D5)

Still I don't want to write one formula gathering all conditions. In the real example, there are more than 50 conditions & it is impossible to rely on one if formula. I would prefer to add those conditions in a separate sheet where it return the error message if correct (condition is met) and empty cell if false. Then, write a simple formula to look for any errors if exist. If any error exists, then the vlookup should return that error otherwise shows the price.
 
Upvote 0
Re: Need Help - Conditional Result in Excel

Still I don't want to write one formula gathering all conditions. In the real example, there are more than 50 conditions & it is impossible to rely on one if formula. I would prefer to add those conditions in a separate sheet where it return the error message if correct (condition is met) and empty cell if false. Then, write a simple formula to look for any errors if exist. If any error exists, then the vlookup should return that error otherwise shows the price.

Let's say the all errors are written in A1:A50 in Sheet2. The order I want to make is =IF(Sheet2!A1:A50<>"", look for the text(s) in this range & reflect it, otherwise show D7 which is the valuation)
 
Upvote 0
Re: Need Help - Conditional Result in Excel

Good evening

After so many attempts, I have finally found out the correct formula. I will write it here for other people to avail.

1) First of all: I made a special sheet for conditions. Let's name it Sheet2.

AB
1=if(b1<>"",1,2)=IF(Sheet1!B1>Sheet1!B2,"Error: Invoice Date Must be on/before Delivery Date","")
2=if(b2<>"",1,2)=IF(Sheet1!B3="New York","Error: Location is not covered","")
3=if(b3<>"",1,2)=IF(Sheet1!B4="","Error:Client Name is missing","")
4=if(b4<>"",1,2)=IF(Sheet1!B5<0,"Error: Price is invalid","")

<tbody>
</tbody>


2) Write the following formula in the final price cell B7: =IFERROR(VLOOKUP(1,Sheet2!A1:B4,2,FALSE),D5)
 
Upvote 0

Forum statistics

Threads
1,215,235
Messages
6,123,782
Members
449,123
Latest member
StorageQueen24

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