Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating current month Randy Excel Worksheet Functions 4 November 2nd 08 10:24 AM
calculating by month Jake Excel Worksheet Functions 1 March 30th 08 05:40 PM
Calculating Month Name RestlessAde Excel Discussion (Misc queries) 2 August 1st 05 10:10 PM
Calculating recurring date in following month, calculating # days in that period Walterius Excel Worksheet Functions 6 June 4th 05 11:21 PM
Calculating Last day of month Jon Excel Programming 3 January 22nd 04 09:43 AM


All times are GMT +1. The time now is 01:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"