Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am having a problem with calculating the last day of the current month in excel. If I use the EOMONTH function with parameters NOW() and 0 i.e. EOMONTH(NOW(), 0) in the cell where I want the date to go everything works fine. However
I want to put the EOMONTH into a macro at which point the compiler complain the EOMONTH is not a defined sub or function. Are there any VB functions that will return the last day of the current month thank you in advanced Jon |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jon,
A cool behaviour of DateSerial is that it accepts values outside the bounds of a calendar month/day. This means you can choose month 13, which is interpreted as month 12 + 1 dtmTemp = Now() dtmTemp = DateSerial(Year(dtmTemp), Month(dtmTemp) + 1, 1) - 1 Rob "Jon" wrote in message ... I am having a problem with calculating the last day of the current month in excel. If I use the EOMONTH function with parameters NOW() and 0 i.e. EOMONTH(NOW(), 0) in the cell where I want the date to go everything works fine. However I want to put the EOMONTH into a macro at which point the compiler complain the EOMONTH is not a defined sub or function. Are there any VB functions that will return the last day of the current month thank you in advanced Jon |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jon
In the VBE, go Tools, References and select the atpvbaen.xls option. EOMONTH should work. Tony ----- Jon wrote: ----- I am having a problem with calculating the last day of the current month in excel. If I use the EOMONTH function with parameters NOW() and 0 i.e. EOMONTH(NOW(), 0) in the cell where I want the date to go everything works fine. However I want to put the EOMONTH into a macro at which point the compiler complain the EOMONTH is not a defined sub or function. Are there any VB functions that will return the last day of the current month thank you in advanced Jon |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jon,
Along the same lines as Rob, but a little shorter myDate = DateSerial(Year(Date), Month(Date) + 1, 0) -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Rob van Gelder" wrote in message ... Jon, A cool behaviour of DateSerial is that it accepts values outside the bounds of a calendar month/day. This means you can choose month 13, which is interpreted as month 12 + 1 dtmTemp = Now() dtmTemp = DateSerial(Year(dtmTemp), Month(dtmTemp) + 1, 1) - 1 Rob "Jon" wrote in message ... I am having a problem with calculating the last day of the current month in excel. If I use the EOMONTH function with parameters NOW() and 0 i.e. EOMONTH(NOW(), 0) in the cell where I want the date to go everything works fine. However I want to put the EOMONTH into a macro at which point the compiler complain the EOMONTH is not a defined sub or function. Are there any VB functions that will return the last day of the current month thank you in advanced Jon |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 days in a month | Excel Discussion (Misc queries) |