WORKDAY formula round up (perhaps arrays)

Domyzon

New Member
Joined
Dec 30, 2016
Messages
19
Hello!

I have a problem I am trying to solve.

Problem 1.

1. I have daily dates from 01.01.2017 - 31.12.2017 -> cells B1:NB1
2. I have a cost of 100€ that I have to pay every month, on the 15th, nearest to the WORKDAY.

Anyone knows what formula to use in order to insert it in B2 (just below the first date) and drag it until the end of the year so 100€ would be filled under appropriate dates?
For example, 15.01.2017 is a Sunday, so 100€ would go under 16.01.2017 as it is the closest workday.
 
Put this formula in cell B2 and copy it across to cell NB2...

=IF(DAY(B1)=15-(WEEKDAY(DATE(YEAR(B1),MONTH(B1),15))=7)+(WEEKDAY(DATE(YEAR(B1),MONTH(B1),15))=1),"100€","")
Thank you Rick, that works too! :)
You are welcome; however, this modification to my formula (which cuts out four function calls) should be more efficient...

=IF(DAY(B1)=15-(WEEKDAY(B1-DAY(B1)+15)=7)+(WEEKDAY(B1-DAY(B1)+15)=1),"100€","")
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Another approach, shorter formula:

=IF(OR(AND(DAY(B1)=15,WEEKDAY(B1,2)<6),2*DAY(B1)+WEEKDAY(B1,2)=33),100,"")
 
Upvote 0
Still a bit faster. On the same range of 100000 dates:
- my formula from Post #12: ~0.25 seconds
- your formula from Post #11: ~0.30 seconds
Hmm, surprising, but good to know. I guess an AND and OR function call is faster than a DAY function call.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
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