Pregunta

I am trying to figure out how to do this in the cleanest way possible. I need a formula that will output biweekly dates or the last working day of the Month only if a biweekly date does not land on that date and it occurs before the next biweekly date. The first date in the list will be manually entered and the formula will use that as the first date. For example:

May 15, 2014 (Manually entered)
May 29, 2014 (Formula that output the next biweekly date based on previous cell)
May 30, 2014 (Same Formula that outputs last working day of month based on last date)
June 12, 2014 (..and so on)
June 26, 2014
June 30, 2014
July 10, 2014
July 24, 2014
July 31, 2014

I hope this makes sense. I would prefer to do this using a formula instead of VBA.

¿Fue útil?

Solución

I'm almost embarrassed to post this because its sheer length leads me to believe something more efficient is possible. In case it helps you, however, I'll post it anyway.

I'm assuming your list begins in A1 with the manually-entered date.

In A2, I have the following formula:

=IF(MONTH(A1+14)=MONTH(A1),A1+14,EOMONTH(A1,0)-IF(WEEKDAY(EOMONTH(A1,0),16)<=2,WEEKDAY(EOMONTH(A1,0),16),0))

Then in A3, I have the following formula (which you can drag down as far as you need):

=IF(A2=EOMONTH(A2,0)-IF(WEEKDAY(EOMONTH(A2,0),16)<=2,WEEKDAY(EOMONTH(A2,0),16),0),A1+14,IF(MONTH(A2+14)=MONTH(A2),A2+14,EOMONTH(A2,0)-IF(WEEKDAY(EOMONTH(A2,0),16)<=2,WEEKDAY(EOMONTH(A2,0),16),0)))

Good luck!

EDIT: I'm also assuming that non-working days are defined as Saturdays and Sundays (with no regard for holidays). Holidays will add some more complexity.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top