Thread: Networkdays
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Networkdays

Networkdays is in an addin, so it is not in the WorksheetFunction object.

If you have a reference from this notebook to the Analysis toolpak VBA, then
you can call it like any other VBA function

WrkDaysInMon=Networkdays(StartDate,FinishDate,Work sheets("Lists").Range("V3:
V24"))


If not, then you need to use Application.Run

WrkDaysInMon = _
Application.Run("ATPVBAEN.XLA!NetWorkDays", _
StartDate,FinishDate,Worksheets("Lists").Range("V3 :V24"))


as an example from the immediate window:
dt1 = date - 30
dt2 = date
? Application.Run("ATPVBAEN.XLA!NetWorkDays",dt1,dt2 )
23

--
Regards,
Tom Ogilvy

"GMet" wrote in message
...
I want to use the NETWORKDAYS function in VB. Here is what I have:


WrkDaysInMon=Application.WorksheetFunction.Network days(StartDate,FinishDate,
Worksheets("Lists").Range("V3:V24"))

In the spreadsheet body it works fine with:
=Networkdays(P4,R4,Lists!V3:V24)

When I try to use it in a macro, I get the message "Object doesn't support
this property or method"

What have I done wrong?

TIA
GMet