Yes or No response and shorten formula

Bedford

Active Member
Joined
Feb 3, 2015
Messages
316
Office Version
  1. 365
Platform
  1. MacOS
I have created a monster formula that I need help with 2 issues. First issue is to have the below formula result with a "0" if the dependent cell J7 is set to "No", or if J7 is set to "Yes" it calculates as per the below formula returning the appropriate value.
Next is I'm wondering if there is a way to shorten the formula as I'm wondering if it is too long for calculating more efficiently.

=IFS(AND(D17>=200, D17<=1300),D17-U31-9,AND(D17>1300, D17<=1500),D17-U32-9,AND(D17>1500, D17<=2000),D17-U33-9,AND(D17>2000, D17<=2500),D17-U34-9,AND(D17>2500, D17<=3000),D17-U35-9,AND(D17>3000, D17<=3500),D17-U36-9,AND(D17>3500, D17<=4000),D17-U37-9,AND(D17>4000, D17<=4500),D17-U38-9)

Thank you for any help.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this
Excel Formula:
=IF(J7="No",0,IF(AND(D17>=200,D17<=4500),D17-XLOOKUP(D17,{1300;1500;2000;2500;3000;3500;4000;4500},$U$31:$U$38,1)-9,NA()))

Or if it suits, put those values in the curly braces in my formula above into the worksheet (I've used cells K2:K9) and then use this form of the formula.
Excel Formula:
=IF(J7="No",0,IF(AND(D17>=200,D17<=4500),D17-XLOOKUP(D17,$K$2:$K$9,$U$31:$U$38,1)-9,NA()))


If the answer to Alex's question is "It is not possible for D17 to be outside the range 200 to 4500", then each of the above formulas can be shortened.

Excel Formula:
=(D17-XLOOKUP(D17,{1300;1500;2000;2500;3000;3500;4000;4500},$U$31:$U$38,1)-9)*(J7="Yes")
Excel Formula:
=(D17-XLOOKUP(D17,$K$2:$K$9,$U$31:$U$38,,1)-9)*(J7="Yes")

In all of the above I have assumed that J7 is either "Yes" or "No"
 
Last edited:
Upvote 0
What do you want the result to be if D17 < 200 or D17 > 4500 ?
Alex, I have copied a "Mini Sheet" using the MrExcel Xl2bb function and pasted it here, as I use a mac, I can't be certain it will result in a true mini sheet. If you are able to view the copied sheet, you will note there are reference cells to the formula, column "U", rows; 31 through 38. Seeing the referenced cells might make some sense of what the results should be.
Thank you.

MG Cut Sheet.xlsx
PQRSTU
29Chart of Dimension "A"
30Screen Width"A"
311200</=W</=76
3221300<W</=79
3331500<W</=87
3442000<W</=96
3552500<W</=104
3663000<W</=113
3773500<W</=121
3884000<W</=130
MG SS Width less than 2500
 
Upvote 0
=(D17-XLOOKUP(D17,{1300;1500;2000;2500;3000;3500;4000;4500},$U$31:$U$38,1)-9)*(J7="Yes")

Peter, so this formula resulted in 2545 when D17 was set to 2555, as 2555 is > 2500 it should calculate D17-113-9, resulting in 2433. To add to the final result, if the result of the calculation is >2500, it should /2. I feel I'm asking too much of excel, and I prefer to avoid an array as they seem to be demanding on the cpu of the mac, purchased a dell xps 17 a few months back but struggling with getting use to the trackpad when a mouse can't be convenient.
Thank you.
 
Upvote 0
so this formula resulted in 2545 when D17 was set to 2555
Yes, I have omitted a comma in my formula - see below.

as 2555 is > 2500 it should calculate D17-113-9, resulting in 2433.
I don't understand why that calculation & it is not what your original formula calculated.

Here is the sheet with your original formula in E17 and my corrected formula in E18.
Can you clarify further if this is still incorrect.

23 01 02.xlsm
DEFJPQRSTU
7Yes
16
1725552442Yours
182442Mine
311200</=W</=76
3221300<W</=79
3331500<W</=87
3442000<W</=96
3552500<W</=104
3663000<W</=113
3773500<W</=121
3884000<W</=130
Bedford (2)
Cell Formulas
RangeFormula
E17E17=IFS(AND(D17>=200, D17<=1300),D17-U31-9,AND(D17>1300, D17<=1500),D17-U32-9,AND(D17>1500, D17<=2000),D17-U33-9,AND(D17>2000, D17<=2500),D17-U34-9,AND(D17>2500, D17<=3000),D17-U35-9,AND(D17>3000, D17<=3500),D17-U36-9,AND(D17>3500, D17<=4000),D17-U37-9,AND(D17>4000, D17<=4500),D17-U38-9)
E18E18=(D17-XLOOKUP(D17,{1300;1500;2000;2500;3000;3500;4000;4500},$U$31:$U$38,,1)-9)*(J7="Yes")
 
Upvote 0
=IFS(AND(D17>=200, D17<=1300),D17-U31-9,AND(D17>1300, D17<=1500),D17-U32-9,AND(D17>1500, D17<=2000),D17-U33-9,AND(D17>2000, D17<=2500),D17-U34-9,AND(D17>2500, D17<=3000),D17-U35-9,AND(D17>3000, D17<=3500),D17-U36-9,AND(D17>3500, D17<=4000),D17-U37-9,AND(D17>4000, D17<=4500),D17-U38-9)

Peter, looking at my formula, it seems to have a flaw. It should be subtracting from D17 the appropriate number from column "U", then -9, but it isn't completing the -9. In other words, the resulting 2442 should be -9 to result at 2433.
My mistake.
 
Upvote 0
It should be subtracting from D17 the appropriate number from column "U"
How do we know what "the appropriate number from column U" is?

Your original formula said (in part)

,AND(D17>2500, D17<=3000),D17-U35-9
2555 fits this range, so the calculation would be

D17-U35-9
=2555-104-9
=2442

So the formula is subtracting the 9. If it is the wrong answer then it would seem using U35 is the problem.
 
Upvote 0
How do we know what "the appropriate number from column U" is?

Your original formula said (in part)


2555 fits this range, so the calculation would be

D17-U35-9
=2555-104-9
=2442

So the formula is subtracting the 9. If it is the wrong answer then it would seem using U35 is the problem.
Peter, you are correct with your assumption. In theory it needs to be using U36 (-113) then -9.
 
Upvote 0
In theory it needs to be using U36
If D17 = 2555 should be using U36 then presumably
D17 = 3300 should be using U37
D17 = 3800 should be using U38
D17 = 4300 should be using U39 ... only problem is U39 doesn't contain anything (as far as we know). :confused:

You need to clarify what ranges for D17 should be using what cells from column U.
 
Upvote 0

Forum statistics

Threads
1,216,170
Messages
6,129,274
Members
449,497
Latest member
The Wamp

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