Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Find next Date

One way
Sub next22nd()
x = Day(Date)
'x = 22
MsgBox x
If x < 22 Then
y = DateSerial(Year(Date), Month(Date), 22)
Else
y = DateSerial(Year(Date), Month(Date) + 1, 22)
End If
MsgBox y
End Sub

--
Don Guillett
SalesAid Software

"Justin Smith" wrote in message
...
John Green posted this elegant formula to find the next Friday based on
today's date:

=TODAY()-WEEKDAY(TODAY()+1)+7

I want to do something similar, but in VBA. I want to write a custom
function that will return the next 22nd of the month based on today's
date,
e.g. if today is 3rd December, the function returns 22 December 2006. If
today is 26th December, then 22 January 2007 is returned. Can anyone help?



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Find next Date

Perfect Don, thanks :-)

"Don Guillett" wrote:

One way
Sub next22nd()
x = Day(Date)
'x = 22
MsgBox x
If x < 22 Then
y = DateSerial(Year(Date), Month(Date), 22)
Else
y = DateSerial(Year(Date), Month(Date) + 1, 22)
End If
MsgBox y
End Sub

--
Don Guillett
SalesAid Software

"Justin Smith" wrote in message
...
John Green posted this elegant formula to find the next Friday based on
today's date:

=TODAY()-WEEKDAY(TODAY()+1)+7

I want to do something similar, but in VBA. I want to write a custom
function that will return the next 22nd of the month based on today's
date,
e.g. if today is 3rd December, the function returns 22 December 2006. If
today is 26th December, then 22 January 2007 is returned. Can anyone help?




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
Find Specific date in Biwwekly Based on date jlclyde Excel Discussion (Misc queries) 3 January 27th 09 09:15 PM
Julian date - find next highest date/number jchick0909 Excel Worksheet Functions 1 March 20th 08 11:38 PM
Find the date of the coming up Saturday given the current date. Michael Ermino Excel Worksheet Functions 4 April 11th 07 02:48 AM
Using variables to make a date and using find method to find that. KyWilde Excel Programming 2 April 21st 05 09:43 PM
Find date and copy range based on that date avzundert Excel Programming 2 November 25th 04 10:31 AM


All times are GMT +1. The time now is 02:40 AM.

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"