+ Reply to Thread
Results 1 to 8 of 8

Return value of the last week of the month based on the year and month

  1. #1
    Registered User
    Join Date
    09-14-2013
    Location
    Paris
    MS-Off Ver
    Excel 2007
    Posts
    2

    Return value of the last week of the month based on the year and month

    Hello,

    I have a problem and i dont really know how to fix it. I have a column with some dates all distanced by one week -

    Date Number
    7 jan 2001 50
    14 Jan 2001 65
    21 Jan 2001 70
    28 Jan 2001 68
    4 Feb 2002 70
    11 Feb 2002 42
    18 Feb 2002 46
    25 Feb 2002 29


    I would like a formula that based on the month and year will return the last value it can find for this month and year - So if we have Jan & 2001 it will return 68 (last week), Feb & 2001, it will return 29 (last week).
    The month could sometime be 4 or 5 weeks long so it is really the last value of the month.

    Thanks so much for your help

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Return value of the last week of the month based on the year and month

    those dates leap a year between jan and feb is that correct?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return value of the last week of the month based on the year and month

    Try this...

    Data Range
    A
    B
    C
    D
    E
    1
    -----
    -----
    -----
    2
    7-Jan-2001
    50
    Jan 2001
    68
    3
    14-Jan-2001
    65
    Feb 2002
    29
    4
    21-Jan-2001
    70
    5
    28-Jan-2001
    68
    6
    4-Feb-2002
    70
    7
    11-Feb-2002
    42
    8
    18-Feb-2002
    46
    9
    25-Feb-2002
    29

    D2:D3 = month year as a TEXT entry

    Enter this formula in E2 and copy down:

    =LOOKUP(2,1/(TEXT(A$2:A$9,"mmm yyyy")=D2),B$2:B$9)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Return value of the last week of the month based on the year and month

    Hello

    as an option, u can use array formula confirmed by Control + Shift + Enter

    Please Login or Register  to view this content.
    ps: sample is attachedReturn value of the last week of the month based on the year and month.xlsx
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,317

    Re: Return value of the last week of the month based on the year and month

    Your post does not comply with Rule 8 of our Forum RULES.

    Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    HTH
    Regards, Jeff

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Return value of the last week of the month based on the year and month

    or
    =LOOKUP(2,1/(TEXT(A$2:A$20,"mmmyyyy")=E1&F1),B$2:B$20) with jan in e1 2001 in f1
    or
    =LOOKUP(EOMONTH(DATE(F1,MONTH(DATEVALUE("01-"&E1)),1),0),A1:B20)

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Return value of the last week of the month based on the year and month

    Hi Steve and welcome to the forum,

    Your answer is a combination of understanding VLookup with a TRUE as the last argument and finding the last day of a month.

    Look at http://www.contextures.com/xlFunctions02.html and see if you see why a TRUE in a VLookup will "back up one" when looking down your date column.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  8. #8
    Registered User
    Join Date
    09-14-2013
    Location
    Paris
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Return value of the last week of the month based on the year and month

    Sorry about the cross point guys, it wont happen again
    Thanks for all your help! I think I got it!

+ 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. [SOLVED] Date Formula to Return Week Number in Current Month based on Reporting Period
    By jeversf in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2013, 12:10 PM
  2. Type in Month-Year and return 3rd wednesday of month
    By learntheweek in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2010, 11:29 AM
  3. Replies: 3
    Last Post: 09-25-2007, 10:26 AM
  4. Replies: 3
    Last Post: 06-14-2006, 05:07 PM
  5. Formula to return last day of month for each month in year?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-03-2006, 12:10 AM

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