+ Reply to Thread
Results 1 to 11 of 11

Formula similar to SUMIFS

  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Formula similar to SUMIFS

    Hi all, I understand how the SUMIFS formula works. I need something that does the same, only the formula doesn't return a sum it just returns a cell value - as the colum usually used to "sum" in the SUMIFS formula actually contains text not numbers.

    So for instance I would want the criteria to say, if cells in B:B = 2, and cells in C:C = 10 then return cell A - which may be "chicken".

    Is this possible in excel?

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Formula similar to SUMIFS

    You could try a LOOKUP formula like this

    =LOOKUP(2,1/(B2:B10=2)/(C2:C10=10),A2:A10)
    Last edited by daddylonglegs; 02-09-2011 at 10:02 AM. Reason: edited formula to match description in question - thanks Col!
    Audere est facere

  3. #3
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Formula similar to SUMIFS

    Another formula option is to use DGET().

    If you want to return multiple values (multiple matches) then use the advanced filter instead of formulas.
    Hope that helps,

    Colin

    RAD Excel Blog

  4. #4
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Formula similar to SUMIFS

    Hi both, Colin, I need the result to show on a differnt spreadsheet so the filter suggestion won't work.

    Daddy long legs, that worked fine. How could i modify the forumla to show perhaps a 2nd identical occurance? The formula you prvide will obviously show the first result, but how can i show a 2nd (if applicable)? Thanks

  5. #5
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Formula similar to SUMIFS

    Hi there,
    Quote Originally Posted by cmb80 View Post
    Colin, I need the result to show on a differnt spreadsheet so the filter suggestion won't work.
    The advanced filter can be used to return results on a different workbook or worksheet. You simply have to activate the target sheet before you perform the filtering.

  6. #6
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Formula similar to SUMIFS

    Hi Colin, I wasn;t aware you could do that. Could you briefly explain how I can do this?

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Formula similar to SUMIFS

    Colin's suggestion would probably be the way to go, a formula approach is possible but there's a greater degree of complexity and potential performance problems for larger ranges.

    Having said that......

    You could use this approach.

    In E1 to count the matches

    =SUMPRODUCT((B2:B10=2)*(C2:C10=10))

    and then this formula in E2

    =IF(ROWS(E$2:E2)>E$1,"",INDEX(A$2:A$10,SMALL(IF((B$2:B$10=2)*(C$2:C$10=10),ROW(A$2:A$10)-ROW(A$2)+1),ROWS(E$2:E2))))

    confirmed with CTRL+SHIFT+ENTER and copied down the column

    ....to list the matches

    You get blanks once the matches run out

  8. #8
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Formula similar to SUMIFS

    Quote Originally Posted by cmb80 View Post
    Hi Colin, I wasn;t aware you could do that. Could you briefly explain how I can do this?
    Sure...

    Suppose your worksheet has a range A1:C6 like this:
    Please Login or Register  to view this content.
    Go to another worksheet (where you want the results to be displayed - we will call this the "Results" sheet) and in F1:G2 set up the following criteria range:
    Please Login or Register  to view this content.
    This is the range that defines the criteria the advanced filter should use.


    Then, in cell A1 on the Results worksheet, type in Value1 (which will indicate that you only want to return Value1 matches from the source data).


    Now, with the Results sheet still active:
    • Go to Data > Filter > Advanced Filter
    • Under Action choose "Copy To Another Location"
    • Click on the icon next to List Range and then navigate back to your source data and select it. The textbox will fill with something like Sheet1!$A$1:$C$6 (perhaps with a workbook name infront of it)
    • Click on the icon next to Criteria Range and then choose the criteria range we set up on the Results sheet; something like this.... Sheet2!$F$1:$G$2
    • Click on the icon next to Copy To and choose A1 on the Results Sheet (which is the destination range)
    • Click OK
    You should get a result like this:
    Please Login or Register  to view this content.
    Once you've done the initial set-up it's a 5 second job to refresh the results. You could even automate it with a little VBA if you really wanted.
    Last edited by Colin Legg; 02-09-2011 at 10:29 AM.

  9. #9
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Formula similar to SUMIFS

    Oh fantastic that looks great, so how do i refresh?

  10. #10
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Formula similar to SUMIFS

    Hi,
    Quote Originally Posted by cmb80 View Post
    Oh fantastic that looks great, so how do i refresh?
    Repeat the bullet-pointed actions (you don't need to set up the ranges). If that's too much hassle then you could use a little VBA to perform those actions for you (if interested, start by using the macro recorder).

    Note: you don't need to clear the target range before you do this - it will be automatically cleared for you.

  11. #11
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Formula similar to SUMIFS

    Thanks for your help - every day is a school day

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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