Home » excel » excel – Sum only matched values from two columns

excel – Sum only matched values from two columns

Posted by: admin May 14, 2020 Leave a comment


enter image description here

Hello Everyone,

Does anyone know how to sum the Hours from column B (Hours) if column A numbers matched with column E and sum by months.

Example, take February data as an example, since only 3000 & 4000 existed in both column A & column E, that’s why I need to sum the hours (20+10=30) from column B by it’s month below.

I also attached the example excel sheet below.

Thanks in advance. 🙂

How to&Answers:

You could get complicated with customer functions but if having an extra column (potentially hidden) doesn’t matter then this would work:

In cell D2 enter:


Drag the formula down.

Under each month you can then put:


Drag the formula across

This assumes you can change the month format in either column C or row 22 to be the same, ie. Jan, Feb, Mar or January, February, March etc.

Written on the fly and not tested so excuse any minor errors…


Both answers posted thus far are just fine, but just as an alternative, here’s what I would do. Put this formula in cell D2 and drag it down:

=IF(NOT(ISNA(VLOOKUP(A2, $E$2:$E$20, 1, FALSE))), B2, "")

Then if you make a column containing the names of the months, say from G2 to G7 you have February, March, …, July, you can put this formula into H2 and drag it down:

=SUMIFS($D$2:$D$16, $C$2:$C$16, G2)

That should get what you want.


Put this formula in Cell D2 and drag down:


In row 22, change the month names to be the full name, OR in column C, change the month names to abbreviated 3-letter names, this is so we can make use of the SumIf function.

Then, in Cell B23, put this formula and drag it across:


(I put the formula in row 24 to check against the data you already had in Row 23)

Screenshot of SumIf function results


Shouldn’t be much harder without a helper column. Just make sure you have full month name in row 22 to match column C data then use this formula in B23 copied across