+ Reply to Thread
Results 1 to 5 of 5

Sumif Lookup

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    155

    Sumif Lookup

    Attached is a spreadsheet where I need help with a formula in cell K18. I chose this cell so that you can see how the formula is suppose to work if I copy it above and below this cell. I need to replace the I17 reference that is seen in the formula to show the I cell reference for last time C18 name is seen in column C. C18 is Jackie Ihle. The last time she is seen is in C10. I need the I17 reference to be replaced by the I10 reference since Jackie is last seen in row 10.

    Another example is seen in K12. If I copy the formula change from above to K12, the I11 reference should be replaced by I8 since the last time House is seen in column C is row 8.
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Sumif Lookup

    Yeah, you are going to like this one. I used some helper cells. I recommend you use them too.

    First you are going to have to determine how many times the name appears in column C =COUNTIF($C$1:C18,C18). (Cell P18)

    Then you are going to have to determine where the previous occurrence of the name in column C occurs. =LARGE((($C$1:C18=C18)*ROW($C$1:C18)),COUNTIF($C$1:C18,C18)-P18+2) <- this is an array formula. (Cell Q18)

    Then you need to get the actual value in Column I for this value. =INDEX($I:$I,Q18,1) (Cell R18).
    If you duplicate this formula in cell V18 and then substitute everything back until you eliminated references to the helper cells so that only original cell references are used in the formula, you get: =INDEX($I:$I,LARGE((($C$1:C18=C18)*ROW($C$1:C18)),COUNTIF($C$1:C18,C18)-COUNTIF($C$1:C18,C18)+2),1).

    This is the formula fragment you would have to place in each part of the formula where I17 is referenced. Also entered as an array formula.

    This is not yet enough. You will have to apply the COUNTIF formula and if evaluates to 1 then use the original formula, otherwise, use this formula.

    I have not done these last two steps, but it leads to one very hairy formula. I suggest you modify the formula in cell V18 (wrap it in an if statement with the COUNTIF) and reference it wherever I17 is referenced. Move this formula off to some convenient column and keep it as a helper cell.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: Sumif Lookup

    I am open to having extra columns in the workbook hidden to help the formula work. Are you able to provide me with a formula that will function based on your comments and ideas? Seems like you know what is going on.

  4. #4
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    155

    Re: Sumif Lookup

    Is the attached correct? I think I got it.
    Attached Files Attached Files

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Sumif Lookup

    I told you it would be hairy . As best I can tell, it does look correct. It's equal to column I in the same row for the first occurrence and then the complicated formula for the previous value if not.

    The best way to QA this would be to edit your formula manually in the old spreadsheet and see if it gives you the same answer as the formula in the new spreadsheet. In my testing, I took it as far as to see that I got the value of I10 when the formula was in row 18.

+ 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. Sumif / lookup for a value and sum
    By oursriharsha in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-04-2013, 08:24 AM
  2. [SOLVED] SumIF – 3 way lookup
    By pauldaddyadams in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-25-2013, 11:28 AM
  3. SUMIF &/or LOOKUP
    By cheeky300 in forum Excel General
    Replies: 2
    Last Post: 07-12-2012, 09:01 AM
  4. Lookup or SUMIF ??
    By rufusf in forum Excel General
    Replies: 2
    Last Post: 02-26-2009, 08:02 AM
  5. lookup and sumif?
    By mheinmiller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2008, 03:40 PM
  6. sumIf or lookup?
    By Spaztik in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-18-2008, 10:35 PM
  7. [SOLVED] sumif? lookup?
    By Duane in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-30-2005, 03:06 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