# Formula based on choice

#### RandyD123

##### Board Regular
I have this in a cell:

=IF(Y16<>"Y",0,Z16-H16

MY default is "N" and if I don't change the Y/N cell to Y I want the formula to just subtract Z16-H16

N is in all the cells in the Y/N column by default.

How do I write the formula to just minus H16 from Z16 as a default and still have the formula work if I select "Y"?

I'm not sure if I need to provide more info or not?

Last edited:

### Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

#### jbeaucaire

##### Well-known Member
This should do it:

=(Z16-H16)*(Y16="N")

#### RandyD123

##### Board Regular
I get a "name" error?

#### jbeaucaire

##### Well-known Member
Just copy and paste the formula from this thread. Maybe you left the " " out from around the "N"?

#### RandyD123

##### Board Regular

Yep, but now I lose my value when Y is selected!!!

#### RandyD123

##### Board Regular
I'm not sure why my original formula is not doing what is supposed to do and that is minus Z16 from H16 if Y is a N

#### jbeaucaire

##### Well-known Member

Perhaps I misunderstand. What is supposed to happen for each of the two options?

Y = ?
N = ?

#### RandyD123

##### Board Regular
Y means I'm turning something on
N means I'm turning something off.

#### jbeaucaire

##### Well-known Member
When Y is entered, what should happen?

When N is entered, what should happen?

#### RandyD123

##### Board Regular
jbeaucaire....thanks for taking time to help. The more I look at the formula, it works as intended. As it turns out I just needed the Z16-H16!!! At least that's what I'm thinking at this point. I am going to try this for a few days and see if I'm all set.

Replies
8
Views
156
Replies
2
Views
103
Replies
3
Views
102
Replies
1
Views
228
Replies
7
Views
172

1,127,199
Messages
5,623,315
Members
415,966
Latest member
ctorohuamanchumo

### 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.

### Which adblocker are you using?

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

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