+ Reply to Thread
Results 1 to 4 of 4

Return value based on two variables - year and month

  1. #1
    Registered User
    Join Date
    06-21-2014
    Location
    Sydney
    MS-Off Ver
    2011
    Posts
    92

    Return value based on two variables - year and month

    Dear all

    A member (Flame Retired) solved the original thread and he developed the formula in this sheet (Thank-you ). It works wonderfully and now I need to extend it to match on two variables (both year and month instead of just month). I tried to modify the formula in cell E21 and E22 but not successful.

    Essentially I have a calendar of expenses and need to be able to report on both the calendar and financial year, which is why I need to build the year into this formula. I am hoping to be able to pull a series of reports together to show summary & detailed views of expenses depending on year and month.

    Please see attached.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Return value based on two variables - year and month

    Your sheet layout is a bit formula unfriendly

    See if this method works. (note that this is based on your attached sample, which appears to have had some extra rows inserted where you have added comments to it).

    First create 2 named ranges.

    Named range 1

    Name:- Year
    Refers to:- =OFFSET('FIN ACCS'!$F$4,0,MATCH('FIN ACCS'!$C$12,'FIN ACCS'!$F$2:$W$2,0)-1,4,12)

    Named Range 2

    Name:- Month
    Refers To:- =INDEX(Year,0,MATCH('FIN ACCS'!$D$12,'FIN ACCS'!$F$3:$Q$3,0))

    Then, in C21 Enter =IFERROR(INDEX($C$4:$C$7,SMALL(IF(Month>0,ROW(Month)-ROW(INDEX(Month,1))+1),ROWS($C$21:$C21))),"")

    Which must be Array confirmed by pressing Shift Ctrl and Enter.

    In D21 =IF(C21="","",VLOOKUP(C21,$C$4:$D$7,2,0))

    In E21 =IF(C21="","",INDEX(Month,MATCH(C21,$C$4:$C$7,0)))

    Then drag the formulas down as needed.

    Hope that makes sense.

  3. #3
    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
    80,779

    Re: Return value based on two variables - year and month

    Great solution, Jason!
    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.

  4. #4
    Registered User
    Join Date
    06-21-2014
    Location
    Sydney
    MS-Off Ver
    2011
    Posts
    92

    Re: Return value based on two variables - year and month

    Jason this is just awesome

    Brilliant work. Thank-you very very much

+ 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] Formula to return month and year based on period.
    By hecgroups in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2015, 03:42 PM
  2. [SOLVED] Return month based on day of the year
    By Marco-Kun in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 03-27-2014, 11:58 AM
  3. Change year but keep the month the same based on current year
    By Jamon Fries in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-11-2014, 05:29 PM
  4. Return value of the last week of the month based on the year and month
    By stevekho2 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-14-2013, 11:04 AM
  5. 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
  6. Replies: 3
    Last Post: 06-14-2006, 05:07 PM
  7. 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