Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calculating the end of the month
I have a sheet that needs to be able to alternate between the 15th and
last day of each month. The user will enter a start date, and I need the code to start at this point and jump to the next date. Example: Start date: 01/15/06 run code date: 01/31/06 run code date: 02/15/06 run code date: 02/28/06 and so on. Can anyone help me with this problem? Thank you. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calculating the end of the month
Hi mastermind,
The first of next month can be determined by getting the "0" day for the next month. Here's a function that should work for you. Just pass in the current date, and it will return the next date: Public Function gdtGetNextPeriodEnd(rdtCurrentPeriodEnd _ As Date) As Date If Day(rdtCurrentPeriodEnd) = 15 Then gdtGetNextPeriodEnd = DateSerial(Year( _ rdtCurrentPeriodEnd), Month(rdtCurrentPeriodEnd) _ + 1, 0) Else gdtGetNextPeriodEnd = DateSerial(Year( _ rdtCurrentPeriodEnd), Month(rdtCurrentPeriodEnd) _ + 1, 15) End If End Function -- Regards, Jake Marx www.longhead.com [please keep replies in the newsgroup - email address unmonitored] mastermind wrote: I have a sheet that needs to be able to alternate between the 15th and last day of each month. The user will enter a start date, and I need the code to start at this point and jump to the next date. Example: Start date: 01/15/06 run code date: 01/31/06 run code date: 02/15/06 run code date: 02/28/06 and so on. Can anyone help me with this problem? Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calculating current month | Excel Worksheet Functions | |||
calculating by month | Excel Worksheet Functions | |||
Calculating Month Name | Excel Discussion (Misc queries) | |||
Calculating recurring date in following month, calculating # days in that period | Excel Worksheet Functions | |||
Calculating Last day of month | Excel Programming |