hi
i am trying to create a column that's that reads another column of varying ages of people and project their next medical date. The projected dates need to be <40 add 4 years >40 add 2 years and >50 add 1 year.
thanks
hi
i am trying to create a column that's that reads another column of varying ages of people and project their next medical date. The projected dates need to be <40 add 4 years >40 add 2 years and >50 add 1 year.
thanks
Here is the formula you have been looking for. Paste it in a cell in row 2 and copy down as required.
=WORKDAY(DATE(YEAR($B2)+INDEX({1,2,4},MATCH(DATEDIF($A2,$B2,"Y"),{100,50,40},-1)),MONTH($B2),DAY($B2))-1,1)
The formula requires the person's birthday in column A and the previous check-up date in column B. And this is how it works. Remember to resolve Excel formulas from the center to the left.
DATEDIF($A2,$B2,"Y") calculates the number of years between birthday and check-up, meaning the next check-up wil be determined by the person's age at the time of his last check-up. When he turns up after 4 years he will be older.
MATCH(DATEDIF($A2,$B2,"Y"),{100,50,40},-1)) looks for a match of the age in the array {100,50,40}. Meaning you can't set a checkup for persons of more than 100 years of age (unless you change the formula here). It also means that a person 50 years of age isn't "more than" 50 years old. If you want to see that person sooner, reduce the number to 49.
The MATCH function will return the number 1, 2 or 3. This number is used to select one of the numbers in INDEX({1,2,4},MATCH. It will be either the first, second or third, meaning 1 year, 2 years or 4 years.
The DATE function's syntax is very simple. DATE(Year, Month Day) returns a date. So, the formula takes the date of the last check-up and adds the numbers of years first calculated to the Year component of the DATE function.
Of course, this date might well be a Sunday. Therefore the entire date calculation explained above is embedded in a WORKDAY function. This function is tricked into providing a workday. The formula takes the calculated day, minus one day (=the day before that date) and asks which would be the next workday if we add the taken day back: WORKDAY([Date]-1,1).