Help with nested IF statement

DPChristman

Board Regular
Joined
Sep 4, 2012
Messages
177
Office Version
  1. 365
Platform
  1. Windows
Essentially what I am trying to do is

Calculate number of years by subtracting entered date (T5) form original data (C5)

Currently, my formula reads =IF(T5="n/a","",YEAR(C5)-YEAR(T5))

As a result, if T5 contains n/a, the cell will return a blank field.

However, I would also like to add =IF(T5="","",YEAR(C5)-YEAR(T5)), so the same result is returned if the field is empty.

I have tried =IF(T5="n/a",",",IF(T5="","",YEAR(C5)-YEAR(T5)) With no success. Is there an easy way to do this?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Code:
=IF(OR(T5="n/a",T5=""),"",YEAR(C5)-YEAR(T5))
 
Upvote 0
You want it to display a blank field if T5 is n/a or blank? Try:

=IF(T5="n/a","(removed comma)",IF(T5="","",YEAR(C5)-YEAR(T5))

In your first If statement, if T5="n/a", because you used single quotes around a comma, the comma was inserted in the field. Essentially, getting rid of that comma, gives you a blank field.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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