ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find next Date (https://www.excelbanter.com/excel-programming/379835-re-find-next-date.html)

Don Guillett

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?




Justin Smith

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?





Don Guillett

Find next Date
 
Thanks, You did say VBA but Martins formula is good.

--
Don Guillett
SalesAid Software

"Justin Smith" wrote in message
...
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?








All times are GMT +1. The time now is 07:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com