Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Cannot call the worksheet function Weeknum

Anyone who can shine a light on this?

1) Worksheet functions can be called in VBA by using: Application.
WorksheetFunctionName
2) The worksheet function 'WeekNum' Exists
3) It works fine in my worksheet '=WEEKNUM(NOW(),1)'

Based on these I would say this would also work:

Sub WeekDay()
Dim dt As Date

dt = Now()
MsgBox Application.Weeknum(dt, 1)
End Sub

However I get: "Object doesn't support this property or method" (err#438)

I also know the Weeknum can be directly called from VBA by installing the Add-
In. But I just want to use the worksheet function.

Anyone?

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Cannot call the worksheet function Weeknum

Hi,

Do it this way


Dt = Now()
MyWeek = DatePart("ww", Dt)

Mike


"Michiel via OfficeKB.com" wrote:

Anyone who can shine a light on this?

1) Worksheet functions can be called in VBA by using: Application.
WorksheetFunctionName
2) The worksheet function 'WeekNum' Exists
3) It works fine in my worksheet '=WEEKNUM(NOW(),1)'

Based on these I would say this would also work:

Sub WeekDay()
Dim dt As Date

dt = Now()
MsgBox Application.Weeknum(dt, 1)
End Sub

However I get: "Object doesn't support this property or method" (err#438)

I also know the Weeknum can be directly called from VBA by installing the Add-
In. But I just want to use the worksheet function.

Anyone?

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Cannot call the worksheet function Weeknum

Hi,

I should have added that if you want to use weeknum then try this

MyWeek = Application.Run("ATPVBAEN.XLA!weeknum", dt, 1)

Mike

"Mike H" wrote:

Hi,

Do it this way


Dt = Now()
MyWeek = DatePart("ww", Dt)

Mike


"Michiel via OfficeKB.com" wrote:

Anyone who can shine a light on this?

1) Worksheet functions can be called in VBA by using: Application.
WorksheetFunctionName
2) The worksheet function 'WeekNum' Exists
3) It works fine in my worksheet '=WEEKNUM(NOW(),1)'

Based on these I would say this would also work:

Sub WeekDay()
Dim dt As Date

dt = Now()
MsgBox Application.Weeknum(dt, 1)
End Sub

However I get: "Object doesn't support this property or method" (err#438)

I also know the Weeknum can be directly called from VBA by installing the Add-
In. But I just want to use the worksheet function.

Anyone?

--
Message posted via http://www.officekb.com


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Cannot call the worksheet function Weeknum

Before Excel 2007 use:

MsgBox Evaluate("=WeekNum(Today(),1)")
--
Gary''s Student - gsnu200906
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Cannot call the worksheet function Weeknum

Gents,

Thanks for your reply.
It works!

Great!

ML

Gary''s Student wrote:
Before Excel 2007 use:

MsgBox Evaluate("=WeekNum(Today(),1)")


--
Message posted via http://www.officekb.com

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
How to call a worksheet (as a function) Bernie Excel Discussion (Misc queries) 18 April 20th 09 06:15 PM
How can i call a function on another worksheet Jorge Ribeiro Excel Programming 2 January 21st 09 04:53 PM
Identifying the worksheet and cell that contains a function call Keith Howard Excel Programming 3 December 25th 08 10:16 PM
how to make sure which worksheet call the function lvcha.gouqizi Excel Programming 4 October 21st 05 09:01 PM
can I call a worksheet function from within vba? G.R. Toro Excel Programming 2 September 30th 04 10:05 PM


All times are GMT +1. The time now is 09:08 PM.

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

About Us

"It's about Microsoft Excel"