Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Workday Function in VBA

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Workday Function in VBA

Richard,

Try this

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

Mike


"Richard" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Workday Function in VBA

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.

"Mike H" wrote:

Richard,

Try this

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

Mike


"Richard" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Workday Function in VBA

PrevWrkDay = application.Evaluate("WORKDAY(TODAY(),-1)")

--
__________________________________
HTH

Bob

"Richard" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Better Workday function. XKruodo Excel Worksheet Functions 2 April 8th 10 02:38 PM
WORKDAY Function Connie Martin Excel Worksheet Functions 3 February 11th 10 07:55 PM
WORKDAY function jpac Excel Worksheet Functions 1 December 22nd 06 09:50 PM
Workday function 4110 Excel Worksheet Functions 0 January 19th 06 03:02 PM
How do I get the WORKDAY function? jorfo Excel Discussion (Misc queries) 1 December 4th 04 11:01 PM


All times are GMT +1. The time now is 10:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"