+ Reply to Thread
Results 1 to 7 of 7

How to get week from year to use in formula

  1. #1
    Forum Contributor mikehk's Avatar
    Join Date
    09-05-2017
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    483

    How to get week from year to use in formula

    I am using this formula but gives me #VALUE error
    =STOCKHISTORY(C22,WEEKNUM(DATE(YEAR(O3),MONTH(P2),DAY(P2))),,1,0,1)

    I desire to make the WEEK part dynamic.

    Kindly see the attached file.

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,339

    Re: How to get week from year to use in formula

    The second argument of this formula needs to be a date, not a week number.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: How to get week from year to use in formula

    Please try at P3

    =LET(a,$P$2:P$2,b,LOOKUP(9^9,a),c,DATE(YEAR($O3),MONTH(b),1),d,c-WEEKDAY(c,16)+(COLUMNS(a)-MATCH(9^9,a)+1)*7,IF(MONTH(d)=MONTH(c),STOCKHISTORY($C$22,d,,1,0,2),""))
    Attached Files Attached Files

  4. #4
    Forum Contributor mikehk's Avatar
    Join Date
    09-05-2017
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    483

    Re: How to get week from year to use in formula

    Thank you sooo much Bo_Ry. This works.

  5. #5
    Forum Contributor mikehk's Avatar
    Join Date
    09-05-2017
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    483

    Re: How to get week from year to use in formula

    Dear Bo_Ry,
    I made a change to the month column but unable to fix the formula, can you please help modify the formula.
    Please see the attached file.
    Thank you so much.
    Attached Files Attached Files

  6. #6
    Forum Contributor mikehk's Avatar
    Join Date
    09-05-2017
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    483

    Re: How to get week from year to use in formula

    I get #VALUE error, can someone please help me fix this formula.

    =STOCKHISTORY(A22,WEEKNUM($O32,11),,1,0,1)

    I attach a sample file.

    Thank you in advance.
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,339

    Re: How to get week from year to use in formula

    See post #2 - the second argument requires a DATE, not a week number.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Formula to get Week Number and Year(last, current and next)
    By Wheelie686 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-12-2019, 08:39 PM
  2. [SOLVED] Week Number formula for fiscal year
    By jkmcn691 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-12-2018, 07:25 PM
  3. [SOLVED] week number formula - fiscal year
    By rubz71 in forum Excel General
    Replies: 14
    Last Post: 07-11-2018, 11:16 PM
  4. Replies: 5
    Last Post: 04-11-2017, 09:23 AM
  5. [SOLVED] Macro that displays all the weeks between Start Week and End Week (ends in next year)
    By Tona in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-31-2014, 05:38 AM
  6. Formula for What year it was the previous week
    By mtt23 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-07-2013, 07:46 AM
  7. Week of Year Formula
    By mdalby in forum Excel General
    Replies: 1
    Last Post: 03-09-2005, 07:52 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1