Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Application.WorksheetFunction. (Excel 2003 SP2)

    I would like to find the week number. I thought it would be easy to use the worksheet weeknum function from the analysis toolpack add in, rather than writting my own. However when I use Application.WorksheetFunction, the weeknum function is not available. Is there a way to use worksheet functions from add ins?

    Thanks.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Application.WorksheetFunction. (Excel 2003 SP2)

    You can set a reference to the atpvbaen.xla and then use <code>Weeknum</code> or you could use <code>Format(date, "ww")</code>
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Application.WorksheetFunction. (Excel 2003 SP2)

    <P ID="edit" class=small>(Edited by JohnBF on 11-Sep-07 08:38. Argument order)</P>Not all built in worksheet functions are available to Excel.Application.WorksheetFunction.

    You might try VBA functions such as (untested):

    myweeknum = datediff("ww", dateserial(year(mydate), 1, 0), mydate)
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Application.WorksheetFunction. (Excel 2003 SP2)

    > Format(date, "ww")

    Mo' better, and mine wasn't quite right.
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application.WorksheetFunction. (Excel 2003 SP2)

    Thanks. I did have a reference set. If I had stopped trying to use Application.Workbookfunctions and simply used the object browser I would have found what I was looking for.

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Application.WorksheetFunction. (Excel 2003 SP2)

    Which works fine as long as you're interested in US weeknumbers...
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Application.WorksheetFunction. (Excel 2003 SP2)

    ? You lost me - I thought week numbers were the same on all current CE Gregorian Calendars - what are the alternatives?
    -John ... I float in liquid gardens
    UTC -7ąDS

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Application.WorksheetFunction. (Excel 2003 SP2)

    In the US, week 1 always starts on January 1, regardless of which day of the week that is.
    In many European countries, the definition from ISO 8601 is used: weeks always start on a Monday, and week 1 is the week containing at least 4 days of the year (in other words, the week containing January 4). Hence, week 1 may start anywhere from December 29 of the previous year to January 4 of the current year.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •