Networkdays

  • Thread starter Thread starter GMet
  • Start date Start date
G

GMet

I want to use the NETWORKDAYS function in VB. Here is what I have:

WrkDaysInMon=Application.WorksheetFunction.Networkdays(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
 
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,Worksheets("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
 
Hi GMet

This is a function from the Analysis Toolpak addin

In VBA, go to Tools>References and check ATPVBAEN.XLS
you can use it in your code now without the Application.WorksheetFunction before it
 
Back
Top