Workday Function in VBA

R

Richard

Hi

I am trying to use the excel workday function within my VBA code as follows:

Dim Today As Date
Dim PrevWrkDay As Date

Today = Now()

PrevWrkDay = application.worksheetfunction.workday(today, -1)


I get a runtime error '438' - Object doesn't support this property or method


Can you please advise if I can get around this, without having to refernce a
cell in the spreadsheet.

Thanks in Advance
Richard
 
M

Mike H

Richard,

Try this

PrevWrkDay = Application.Run("ATPVBAEN.XLA!Workday", Date, -1)
PrevWrkDay = Format(PrevWrkDay, "dd/mm/yyyy")

Mike
 
R

Richard

Mike

Thanks looks good right now, best test is either a Monday or first day of
month. I'll let you know how it goes.
 

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

Top