Nested IF using dates questions

Grant22

New Member
Joined
Dec 28, 2016
Messages
48
Hello all, I have a formula that works fine as it is now, but my company went and changed the criteria so I need to add more levels to this formula. Basically, in Cell M1 is the hire date and Cell M2 is the status which is always Part Time or Full Time. Right now the formula uses the date as a number to calculate the number of vacation hours earned (I.E. if they've been there more than 15 years and they're full time they it calculates 200 hours).

But I'm needing to add another level where if they where hired before April 30th of the current year they get 80 hours, if hired between May 1st and August 31st they get 40 hours and after September 1st they get 0. The formula below works fine but I'm not sure how to add the extra checks into the IF statement.

Note: The formula is all written as one line in the excel FX box, I just broke it into single lines cause I thought it would be easier to read. :)

Any help is greatly appreciated.

Code:
=IF(ISBLANK(M1),0,
IF(AND(M2="Part Time",M1<(TODAY()-5475)),137,
IF(AND(M2="Part Time",M1<(TODAY()-2555)),104,
IF(AND(M2="Part Time",M1<(TODAY()-1825)),80,
IF(AND(M2="Part Time",M1<(TODAY()-1)),48,
IF(AND(M2="Full Time",M1<(TODAY()-5475)),200,
IF(AND(M2="Full Time",M1<(TODAY()-2555)),160,
IF(AND(M2="Full Time",M1<(TODAY()-1825)),120,
IF(AND(M2="Full Time",M1<(TODAY()-1)),80,0
)))))))))

'or the correct way:

=IF(ISBLANK(M1),0,IF(AND(M2="Part Time",M1<(TODAY()-5475)),137,IF(AND(M2="Part Time",M1<(TODAY()-2555)),104,IF(AND(M2="Part Time",M1<(TODAY()-1825)),80,IF(AND(M2="Part Time",M1<(TODAY()-1)),48,IF(AND(M2="Full Time",M1<(TODAY()-5475)),200,IF(AND(M2="Full Time",M1<(TODAY()-2555)),160,IF(AND(M2="Full Time",M1<(TODAY()-1825)),120,IF(AND(M2="Full Time",M1<(TODAY()-1)),80,0)))))))))
 
You are welcome!

I don't know if you have any experience with CASE statements, but they are very handy in VBA. The sure look a lot nicer and are easier to follow than a bunch of nested IF statements.
For more on them, you can read this here: https://www.techonthenet.com/excel/formulas/case.php
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,216,192
Messages
6,129,443
Members
449,509
Latest member
ajbooisen

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