Excel compares two columns in different sheets returns the value of the third cell

advertisements

I have two sheets
SHEET A contains more than 1500 entries like this

    A       B      C
  Year   Month  Births
  1880     1     530
  1880     2     456
  1880     3     234
  1890     1     163
  1890     2     123
  1890     3     125

Sheet 2 is similar but column C has no entries and there are only a few years and months in random years and months:

    A       B      C
  Year   Month  Births
  1880     1
  1890     2
  1890     3

I am trying to find a formula to return the value from Sheet 1 | column C to Sheet 2 | column C if column A and B in Sheet 1 are the same as in column A and B in sheet 2.

I am looking for a formula, no VBA since I can't always use it.
And been unable to adapt anything I find here at stackoverflow.

thx


This can be done really easily with =SUMIFS(). Something like the following should do the trick:

=SUMIFS(Sheet1!C:C, Sheet1!A:A, Sheet2!A2, Sheet1!B:B, Sheet2!B2)

Put that in Sheet2 Cell C2 and copy down.

If you are in an excel version before Excel 2007 (when SUMIFS was added) you can use =SUMPRODUCTS() do to the same thing, although the format is a bit different. Let me know and I'll type that one out too.