Complicated IF statement driving me crazy

Clelv

New Member
Joined
Dec 19, 2016
Messages
33
Hi All

ABCD EFGHI
1SU IDTransfer LocationStart DateStart DetailsDate of 1st TransferTransfer DetailsDate of 2nd TransferTransfer DetailsEnd Date
209/01/2017RR05/04/2017DC»»»»»»29/04/20172424
325/01/2017RR21/04/2017DC06/05/2017RR20/05/20171515
404/01/2017RR10/04/2017DC»»»»»»06/05/20172626
526/01/2017RR25/04/2017DC»»»»»»20/05/20172525
618/01/2017RR18/04/2017DC»»»»»»13/05/20172525
705/01/2017RR08/04/2017trev»»»»»»22/04/20171414
821/03/2017RR30/05/2017DC»»»»»»10/06/20171111
9 01/03/2017DC30/05/2017RR»»»»»»24/06/2017900
1002/03/2017RR30/05/2017DC»»»»»»09/06/20171010
11 16/03/2017DC10/06/2017RR15/06/2017DC17/06/20178888
1230/03/2017RR26/06/2017DC»»»»»»Current00
1328/11/2016RR06/03/2017DC»»»»»»01/04/20172626
1402/05/2017DC»»»»»»»»»»»»01/06/2017300

<colgroup><col><col><col><col><col><col><col><col><col><col><col span="3"></colgroup><tbody>
</tbody>


This is a table of data i've been working on. the second to end column adds up how many days the Service user required DC (DAY CARE). I somehow got there with this formula:

=IFERROR(IF(AND($I3="DC",$E3="DC"),$J3-$H3+$F3-$D3,
IF(AND($G3="DC",$I3="RR"),$H3-$F3,
IF(AND($E3="DC",$G3="RR"),$F3-$D3,
IF(AND($E3="DC",$G3="»»»"),$J3-$D3,$J3-$F3)))),0)


In the end column i'm attempting to do the same but have written the formula using <> to enable me to type text other than "DC" but get the same results as in cell F7 where i've used "trev" instead of "DC" and have been given the same outcome.

For some reason though this formula misses row 9. where i want to count the days between E9 and C9 and i just cannot get to the bottom of it and it's driving me nuts!! this is the formula i'm using. I would be really grateful if someone can spot the flaw/flaws. Thanks

=IFERROR(IF(AND($I3<>"RR",$E3<>"RR"),$J3-$H3+$F3-$D3,
IF(AND($G3<>"RR",$I3="RR"),$H3-$F3,
IF(AND($E3<>"RR",$G3="RR"),$F3-$D3,
IF(AND($E3<>"RR",$G3="»»»"),$J3-$D3,$J3-$F3)))),0)
 
I think I've done it. Just added H9<>"»»»" into the and statement and it gave me the 90 I've been looking for. Amazing! I know it's slightly bodged but it's bringing back the right numbers now so I'm over the moon.

I'd never have got there without your help thanks Joe4. Saved my sanity!
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
You are welcome!

Yes, people often get really confused about when to use AND or OR, especially when dealing with "not equal". It is almost like a double-negative, and isn't always clearly intuitive.
 
Upvote 0
I can't believe it, I'd just cracked it and then you sent it me too. Amazing

Thank you so so much Joe4, I know it's slightly bodged but it's returning the right count of days now so I'm absolutely over the moon and will keep what's left of my sanity haha

There's no way I'd of got this right without your help. Thanks Again.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,794
Members
449,468
Latest member
AGreen17

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