Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default WorksheetFunction.EOMonth

Can this worksheet function be replicated in VBA? I would like to get the end
of any given month, Any Thoughts?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default WorksheetFunction.EOMonth

Function eom(dteDate As Date) As Date
eom = (DateAdd("m", 1, dteDate - (Day(dteDate) - 1))) - 1
End Function

--
Thanks,

Michael Kucan


"Office_Novice" wrote:

Can this worksheet function be replicated in VBA? I would like to get the end
of any given month, Any Thoughts?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default WorksheetFunction.EOMonth

Hi

Within the VBE go ToolsReferences and set a reference to atpvbaen.xls (the
Analysis Toolpak) and then you can use the functions it contains within your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in message
...
Can this worksheet function be replicated in VBA? I would like to get the
end
of any given month, Any Thoughts?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default WorksheetFunction.EOMonth

tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to atpvbaen.xls (the
Analysis Toolpak) and then you can use the functions it contains within your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in message
...
Can this worksheet function be replicated in VBA? I would like to get the
end
of any given month, Any Thoughts?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default WorksheetFunction.EOMonth

You can call Excel worksheet functions, including functions in the
Analysis Tool Pack (such as EOMonth) from VBA. The EOMonth function is
in the ATP, so you don't call it via Application.WorksheetFunction.
Instead, there is an add-in you can reference to call the function
directly. See
http://www.cpearson.com/Excel/Callin...ionsInVBA.aspx



Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email is on the web site)
USA Central Daylight Time (-5:00 GMT)


On Fri, 10 Oct 2008 10:37:24 -0700, Office_Novice
wrote:

Can this worksheet function be replicated in VBA? I would like to get the end
of any given month, Any Thoughts?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default WorksheetFunction.EOMonth

Maybe

mydate = "1/1/2008"
lastday = Format(DateAdd("m", 1, mydate) - Day(mydate), "dd/mm/yyyy")

Mike

"Office_Novice" wrote:

Can this worksheet function be replicated in VBA? I would like to get the end
of any given month, Any Thoughts?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default WorksheetFunction.EOMonth

A more direct approach, in my opinion...

Function eom(dteDate As Date) As Date
eom = DateSerial(Year(dteDate), Month(dteDate) + 1, 0)
End Function
--
Rick (MVP - Excel)


"Michael Kucan" wrote in message
...
Function eom(dteDate As Date) As Date
eom = (DateAdd("m", 1, dteDate - (Day(dteDate) - 1))) - 1
End Function

--
Thanks,

Michael Kucan


"Office_Novice" wrote:

Can this worksheet function be replicated in VBA? I would like to get the
end
of any given month, Any Thoughts?


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default WorksheetFunction.EOMonth

Hello Mike

What seems to be the problem?

Richard



"Mike H" wrote in message
...
tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to atpvbaen.xls
(the
Analysis Toolpak) and then you can use the functions it contains within
your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in message
...
Can this worksheet function be replicated in VBA? I would like to get
the
end
of any given month, Any Thoughts?



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default WorksheetFunction.EOMonth

I believe your method only works for E2007, for earlier

MsgBox Format([atpvbaen.xls].EoMonth(Now, 5), "DD/MM/YYYY")

Mike

"Richard Schollar" wrote:

Hello Mike

What seems to be the problem?

Richard



"Mike H" wrote in message
...
tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to atpvbaen.xls
(the
Analysis Toolpak) and then you can use the functions it contains within
your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in message
...
Can this worksheet function be replicated in VBA? I would like to get
the
end
of any given month, Any Thoughts?


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default WorksheetFunction.EOMonth

Worked for me in 2003 ;-)

--
Richard Schollar

Microsoft MVP - Excel
"Mike H" wrote in message
...
I believe your method only works for E2007, for earlier

MsgBox Format([atpvbaen.xls].EoMonth(Now, 5), "DD/MM/YYYY")

Mike

"Richard Schollar" wrote:

Hello Mike

What seems to be the problem?

Richard



"Mike H" wrote in message
...
tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to atpvbaen.xls
(the
Analysis Toolpak) and then you can use the functions it contains
within
your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in
message
...
Can this worksheet function be replicated in VBA? I would like to
get
the
end
of any given month, Any Thoughts?





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default WorksheetFunction.EOMonth

well that's most odd, even with the reference set in VB and on the worksheet
addins I can't do it. I'm puzzled

"Richard Schollar" wrote:

Worked for me in 2003 ;-)

--
Richard Schollar

Microsoft MVP - Excel
"Mike H" wrote in message
...
I believe your method only works for E2007, for earlier

MsgBox Format([atpvbaen.xls].EoMonth(Now, 5), "DD/MM/YYYY")

Mike

"Richard Schollar" wrote:

Hello Mike

What seems to be the problem?

Richard



"Mike H" wrote in message
...
tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to atpvbaen.xls
(the
Analysis Toolpak) and then you can use the functions it contains
within
your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in
message
...
Can this worksheet function be replicated in VBA? I would like to
get
the
end
of any given month, Any Thoughts?



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default WorksheetFunction.EOMonth

Mike

Probably unlikely I realise but you don't have another UDF function in an
open workbook called Eomonth do you?

--
Richard Schollar

Microsoft MVP - Excel


"Mike H" wrote in message
...
well that's most odd, even with the reference set in VB and on the
worksheet
addins I can't do it. I'm puzzled

"Richard Schollar" wrote:

Worked for me in 2003 ;-)

--
Richard Schollar

Microsoft MVP - Excel
"Mike H" wrote in message
...
I believe your method only works for E2007, for earlier

MsgBox Format([atpvbaen.xls].EoMonth(Now, 5), "DD/MM/YYYY")

Mike

"Richard Schollar" wrote:

Hello Mike

What seems to be the problem?

Richard



"Mike H" wrote in message
...
tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to
atpvbaen.xls
(the
Analysis Toolpak) and then you can use the functions it contains
within
your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in
message
...
Can this worksheet function be replicated in VBA? I would like to
get
the
end
of any given month, Any Thoughts?




  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default WorksheetFunction.EOMonth

No,

I've been delving deeper and I'm still struggling to understand why. I can
call all the functions using

MsgBox Format([atpvbaen.xls]....etc

But not with the reference set

Mike

"Richard Schollar" wrote:

Mike

Probably unlikely I realise but you don't have another UDF function in an
open workbook called Eomonth do you?

--
Richard Schollar

Microsoft MVP - Excel


"Mike H" wrote in message
...
well that's most odd, even with the reference set in VB and on the
worksheet
addins I can't do it. I'm puzzled

"Richard Schollar" wrote:

Worked for me in 2003 ;-)

--
Richard Schollar

Microsoft MVP - Excel
"Mike H" wrote in message
...
I believe your method only works for E2007, for earlier

MsgBox Format([atpvbaen.xls].EoMonth(Now, 5), "DD/MM/YYYY")

Mike

"Richard Schollar" wrote:

Hello Mike

What seems to be the problem?

Richard



"Mike H" wrote in message
...
tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to
atpvbaen.xls
(the
Analysis Toolpak) and then you can use the functions it contains
within
your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote in
message
...
Can this worksheet function be replicated in VBA? I would like to
get
the
end
of any given month, Any Thoughts?




  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default WorksheetFunction.EOMonth

I'm really not sure why that would be the case. I had a fiddle with my
settings and stuff but haven't been able to recreate the situation you have.
I'll post back if I stumble across anything.

--
Richard Schollar

Microsoft MVP - Excel


"Mike H" wrote in message
...
No,

I've been delving deeper and I'm still struggling to understand why. I can
call all the functions using

MsgBox Format([atpvbaen.xls]....etc

But not with the reference set

Mike

"Richard Schollar" wrote:

Mike

Probably unlikely I realise but you don't have another UDF function in an
open workbook called Eomonth do you?

--
Richard Schollar

Microsoft MVP - Excel


"Mike H" wrote in message
...
well that's most odd, even with the reference set in VB and on the
worksheet
addins I can't do it. I'm puzzled

"Richard Schollar" wrote:

Worked for me in 2003 ;-)

--
Richard Schollar

Microsoft MVP - Excel
"Mike H" wrote in message
...
I believe your method only works for E2007, for earlier

MsgBox Format([atpvbaen.xls].EoMonth(Now, 5), "DD/MM/YYYY")

Mike

"Richard Schollar" wrote:

Hello Mike

What seems to be the problem?

Richard



"Mike H" wrote in message
...
tested?

"Richard Schollar" wrote:

Hi

Within the VBE go ToolsReferences and set a reference to
atpvbaen.xls
(the
Analysis Toolpak) and then you can use the functions it contains
within
your
code eg:

MsgBox Eomonth(Date,5)

Richard



"Office_Novice" wrote
in
message
...
Can this worksheet function be replicated in VBA? I would like
to
get
the
end
of any given month, Any Thoughts?





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
EOMONTH question Geo Excel Discussion (Misc queries) 6 October 17th 07 09:28 PM
eomonth John T[_2_] Excel Worksheet Functions 3 March 15th 07 12:51 PM
EOMONTH error puppethead Excel Worksheet Functions 2 March 31st 06 11:00 AM
Every time I try to use EOMonth I get #Name? David Excel Worksheet Functions 2 September 30th 05 11:28 PM
WorkSheetFunction.CountIf & WorkSheetFunction.SumIf with 2 conditions? Etien[_2_] Excel Programming 3 January 13th 04 04:07 PM


All times are GMT +1. The time now is 10:54 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"