Help with nested IF statement

DPChristman

Board Regular
Joined
Sep 4, 2012
Messages
171
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

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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