Networkdays

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
 
T

Tom Ogilvy

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
 
R

Ron de Bruin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top