View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Cimjet[_4_] Cimjet[_4_] is offline
external usenet poster
 
Posts: 29
Default Find last weekday of the month with vba for all months

On Monday, September 24, 2012 9:05:04 PM UTC-4, Ron Rosenfeld wrote:
On Mon, 24 Sep 2012 16:35:19 -0700 (PDT), Cimjet wrote:



Hi Ron


You read my mind, I'm using XL03 and looking at your formula, I was sure it would work,it's almost the same as the cell function but no luck


I still need your help.


Thanks


John




OK, let me see if I can remember this. And I can't test it as I don't have Excel 2003 installed.



In Excel 2003, the WORKDAY function is part of the Analysis Tool Pak. To use it in VBA, do the following:



Open Excel; and select Tools/Add-Ins

Select: Analysis ToolPak - VBA (If that is not there, you will have to browse for it; try something like C:\Program Files\Microsoft Office\Office\Library or do a search)

Then open the VBA Editor.

Select Tools/References

Select the reference to atpvbaen.xls



You should now be able to use the Workday function directly in your VBA macro. So, in the macro, remove the "worksheetfunction." before the Workday, so it looks like:



dLastWDOM = WorkDay(DateSerial(Year(Date), Month(Date) + 1, 1), -1)

Hi Ron

This time it's tried and tested and it works great.
I knew about the Analysis ToolPak and atpvbaen.xla, I just couldn't get the syntax right.
Thanks again
John