Formula Help with Nested If

mayoung

Active Member
Joined
Mar 26, 2014
Messages
257
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
=IF(D4="",0,IF(D5="",TODAY()-D4,D5-D4,IF(G4="C",D4-D3,)))

For the above formula I am getting the Error: You've entered to many arguments for this function.

Please help and explain what I am doing wrong? If I just put the first two if statements they work fine. It's when I enter the third if statement I get the error.

Thank You
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
This is the right syntax. Though I don't know it's the logic you want.


=IF(D4="",0,IF(D5="",TODAY()-D4,IF(G4="C",D4-D3,D5-D4)))


 
Upvote 0
How can I get the 3rd If Statement to over ride the second If Statement.

What I am wanting to do if D5 is blank and G4 does not equal C I am wanting Today () -D4.

But if D5 is Blank and G4 does equal C I am wanting D4-D3.

How can I accomplish this?
 
Upvote 0
how can i get the 3rd if statement to over ride the second if statement.

What i am wanting to do if d5 is blank and g4 does not equal c i am wanting today () -d4.

But if d5 is blank and g4 does equal c i am wanting d4-d3.

How can i accomplish this?

Try this...

=IF(D4="",0,IF(D5="",IF(G4<>"C",TODAY()-D4,D4-D3),D5-D4))
 
Last edited:
Upvote 0
Hi @mayoung

this might help you in future with IF statements as they can be tricky to understand and read especially if they are nested.

Just remember that the syntax is: <code>=IF (Logic_Test, Value_if_True, Value_if_False)</code>

So you must always have 3 parts to every IF in your formula. It helps if you include 'returns' in the formula when you enter into the cell in Excel to make it easier to read (press ALT enter in the cell). I have re-arranged the formula provided @AlphaFrog (and changed it slightly) to help show the 3 parts for each IF.

Blue is the first part
Orange is the second part
Pink is the third part
Black has already been evaluated

First IF - test if D4 is blank:
=IF(D4="",0,
IF(D5<>"", D5-D4,
IF(G4<>"C",TODAY()-D4,D4-D3))


Second IF - D4 was not blank so test if D5 is blank:
=IF(D4="",0,
IF(D5<>"", D5-D4,
IF(G4<>"C",TODAY()-D4,D4-D3))


Third part - D5 was blank so test if G4 is 'C':
=IF(D4="",0,
IF(D5<>"", D5-D4,
IF(G4<>"C",TODAY()-D4,D4-D3))

I hope this helps.
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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