Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find Specific date in Biwwekly Based on date | Excel Discussion (Misc queries) | |||
Julian date - find next highest date/number | Excel Worksheet Functions | |||
Find the date of the coming up Saturday given the current date. | Excel Worksheet Functions | |||
Using variables to make a date and using find method to find that. | Excel Programming | |||
Find date and copy range based on that date | Excel Programming |