Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot call the worksheet function Weeknum
Before Excel 2007 use:
MsgBox Evaluate("=WeekNum(Today(),1)") -- Gary''s Student - gsnu200906 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to call a worksheet (as a function) | Excel Discussion (Misc queries) | |||
How can i call a function on another worksheet | Excel Programming | |||
Identifying the worksheet and cell that contains a function call | Excel Programming | |||
how to make sure which worksheet call the function | Excel Programming | |||
can I call a worksheet function from within vba? | Excel Programming |