+ Reply to Thread
Results 1 to 5 of 5

If, vlookup, sum??

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-18-2012
    Location
    new york
    MS-Off Ver
    Office 365
    Posts
    177

    If, vlookup, sum??

    I am struggling with a formula that will do the following:

    If cell C4 = "Past 12 Months", sum all of the values in sheet 2 for that UFN
    If cell C4 = "Past 6 Months", sum Jan to June in sheet 2 for that UFN
    If cell C4 = "Past 3 Months", sum Apr to June in sheet 2 for that UFN

    I hope this makes sense! I can get the IF formula part ok but I am struggling to figure out the Vlook up side of things.
    test wb.xlsx
    I have attached a sample workbook. Formula should be in the Value column (D4).

    Thanks!

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: If, vlookup, sum??

    Try this.....

    In D4
    =IF(C4="Past 12 Months",SUM(OFFSET(INDEX(Table1[jan],MATCH(Sheet2!B4,Table1[UFN],0)),,,,12)),IF(C4="Past 6 Months",SUM(OFFSET(INDEX(Table1[jan],MATCH(Sheet2!B4,Table1[UFN],0)),,,,6)),SUM(OFFSET(INDEX(Table1[jan],MATCH(Sheet2!B4,Table1[UFN],0)),,3,,3))))
    and then copy down.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,693

    Re: If, vlookup, sum??

    Put this in D4 and copy down. VLOOKUP returns only a single value so that's not what you need. This formula will return the string "error" if the value in C4 is none of the three that you listed.

    =IF(C4="Past 12 Months",SUM(OFFSET(Table1[[#Headers],[jan]:[dec]],MATCH(B4,Table1[UFN],0),0)),IF(C4="Past 6 Months",SUM(OFFSET(Table1[[#Headers],[jan]:[jun]],MATCH(B4,Table1[UFN],0),0)),IF(C4="Past 3 Months",SUM(OFFSET(Table1[[#Headers],[jan]:[mar]],MATCH(B4,Table1[UFN],0),0)),"error")))
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,693

    Re: If, vlookup, sum??

    Here is an even shorter formula. The list of strings in LOOKUP must be in exactly the order shown.

    =SUM(OFFSET(Table1[[#Headers],[jan]],MATCH(B4,Table1[UFN],0),0,1,LOOKUP(C4,{"Past 12 Months","Past 3 Months","Past 6 Months"},{12,3,6})))

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: If, vlookup, sum??

    Pl see attached file.
    Attached Files Attached Files

+ 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. Replies: 0
    Last Post: 12-26-2013, 01:12 PM
  2. Display Cell within VLookup range that excel thinks matches the VLookup Value
    By headachexcelperson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-04-2013, 04:56 PM
  3. [SOLVED] Vlookup is not working and giving =vlookup(B2,$T$2:$U$135,2,false) this kind of values.
    By yogeshsharma1981 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-09-2013, 04:08 PM
  4. vlookup? match? index? MULTIPLE criteria for vlookup search problem....
    By aborg88 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-11-2013, 09:56 AM
  5. Replies: 5
    Last Post: 07-29-2009, 07:53 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