A challenge for you... End of the month plus more!

slay0r

Board Regular
Joined
Jul 8, 2011
Messages
231
Hey guys..this is a bit complicated so bear with me but it should be a suitable challenge for you experts!

I basically need to know what will be outstanding at the end of the month that is OVER 45 days (at the end of the month though..not now!) The issue is that the end of month command isn't sufficient because it might fall on a weekend so I can't say it's the 1st of this month or the 2nd of this month because it's not on a set day, it's on the first working day of the month so for example the next 3 months it will be 1st November, 3rd December, 2nd January. Is there any code I can use to do this?

I need it to delete anything that isn't within the above range so then I can manipulate the data as I plan to. From the below example the top line would be deleted as by the 1st of November which is the first working day of the month it will be only 25 days old so therefore not over 45 days at the end of the month (or beginning of the next month if that command is easier?!) The second line will be included because although it's only 41 days old today on the 24th October 2012, it will be 49 days old by the time it hits 1st November. Hope that makes sense

Any help would be incredibly appreciated, I'm stumped on this one..

Company
Alpha
Long
Invoice Date
Invoice Age
Total O/S
CC Section
130
Test1
Testlonger1
08/10/12
17
1231.54
Tom
147
Test2
Testlonger2
14/09/12
41
3527.23
Laura
147
Test3
Testlonger3
11/11/11
349
129.42
Tom
130
Test4
Testlonger4
03/05/12
175
1532.98
Steph

<TBODY>
</TBODY>
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Not the shortest formula in the world, but this returns the first weekday (assuming weekdays are Mon-Fri) of next month:
Code:
=MIN(IF(WEEKDAY(DATE(YEAR(NOW()),MONTH(NOW())+1,1),2)<6,DATE(YEAR(NOW()),MONTH(NOW())+1,1),NOW()+360),IF(WEEKDAY(DATE(YEAR(NOW()),MONTH(NOW())+1,2),2)<6,DATE(YEAR(NOW()),MONTH(NOW())+1,2),NOW()+360),IF(WEEKDAY(DATE(YEAR(NOW()),MONTH(NOW())+1,3),2)<6,DATE(YEAR(NOW()),MONTH(NOW())+1,3),NOW()+360))
This works by:
* Using DATE() and NOW() to get the first day of next month
* Using WEEKDAY(,2) to get the weekday number (1=Mon, 7=Sun)
* Using IF() to test the weekday and if Mon-Fri, return the date, else return a date 360 days from now
* Using MIN() to choose the earliest date, with three similar formulae to test the 1st, 2nd and 3rd of next month

By replacing now() with a reference to a cell (e.g. cell A1), you can enter any date in the cell and get the first weekday of the month following that date:
Code:
=MIN(IF(WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,1),2)<6,DATE(YEAR(A1),MONTH(A1)+1,1),A1+360),IF(WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,2),2)<6,DATE(YEAR(A1),MONTH(A1)+1,2),A1+360),IF(WEEKDAY(DATE(YEAR(A1),MONTH(A1)+1,3),2)<6,DATE(YEAR(A1),MONTH(A1)+1,3),A1+360))

You could use this by adding another column calculating the age as at first working day of next month and filtering on those rows with the 45 days or more result
 
Upvote 0
Guys that's perfect apart from one small thing, if the date is last year it does it to last years month so for example 10/10/11 comes out as 03/11/11 rather than this month, is there a simple fix for that?
 
Upvote 0
The reason is because I want to calculate the difference between the invoice date and the first working day of next month (I thought it was going to be more complicated than this but as it works out it can be this simple!)

E.g I want to use the Invoice date from the example above, then use the first working day from next month so in this case ONLY November to work out how many days there are from invoice date to the end of THIS month (well the beginning of next month) , a working example of what I'm trying to do below:

Invoice date: EOM DATE DAYS:

10/09/2012 01/10/2012 21
10/10/2012 01/11/2012 22

If you see what I mean from that, the top line in red should actually be 52 days to the beginning of next month which means it will be over the 45 day threshold I want to use as a filter, what I need is for the formula to use the beginning of next month from the current month not from the cell month. I'm even confusing myself here! Hope that helps a bit..
 
Upvote 0
You sir, are a massive legend. Thanks to the other guys for their help as well, it's always appreciated!
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,428
Members
448,896
Latest member
MadMarty

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