+ Reply to Thread
Results 1 to 6 of 6

Conditional sum or Sumif?

  1. #1
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Conditional sum or Sumif?

    Hi.

    I'm trying to create a function to solve the following.

    Column A contains numbers representing years. Column B contains numbers representing population. Each year number in A has a corresponding population # in B. I'm trying to sum the numbers in B that correspond to years between 20 & 30.

    Exl:

    A B
    15 5
    20 6
    25 7
    30 6
    35 5

    The result I'm looking for would be sum(6+7+6) = 19

    Any help is greatly appreciated.

    Thank you.

  2. #2
    Valued Forum Contributor
    Join Date
    10-10-2012
    Location
    New York
    MS-Off Ver
    Excel 2007/2010
    Posts
    337

    Re: Conditional sum or Sumif?

    Try this

    =SUMPRODUCT(--($A:$A>=20)*($A:$A<=30),$B:$B)

  3. #3
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Conditional sum or Sumif?

    =sumproduct(--($a$1:$a$5>=20),--($a$1:$a$5<=30),$b$1:$b$5)

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Conditional sum or Sumif?

    or this...
    =SUMIFS(B2:B6,A2:A6,">="&20,A2:A6,"<="&30)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Forum Contributor
    Join Date
    10-16-2012
    Location
    Brooklyn
    MS-Off Ver
    Excel 2010 PC
    Posts
    137

    Re: Conditional sum or Sumif?

    Ah ha. Thank you all very much. This is exactly what I was trying to do.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Conditional sum or Sumif?

    Happy to help and thanks for the feedback

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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