Thread: Sum specific cells based on value in another cell. Thanks: 0 Likes: 0

1. Sum specific cells based on value in another cell.

I would like to create a formula to automatically add the total hours per labeled time block based on the text above it. For example, I would like the formula to add the value in F26 based on the text in E24. to Does anyone know if this is possible, and if so what formula should I use? Please help!

2. Re: Sum specific cells based on value in another cell.

Welcome to the MrExcel forum.

For future reference, it's better to use one of the HTML tools (see my signature) to show your data. It's much easier for the helpers here to copy that onto their test spreadsheets than it is for them to actually have to retype everything. I normally wouldn't do it either, but I had some free time.

See if this works for you:

Excel 2012
B C D E F G H I J K L
24 7-L 7-L KAS KAS
25 Time In Total 8:00 AM Total 7:40 AM Total 8:00 AM Total 8:00 AM Total
26 Time Out 0:00 10:00 AM 2:00 9:30 AM 1:50 1:00 PM 5:00 12:00 PM 4:00
27 KAS KAS KAS 7-L
28 Time In Total 10:00 AM Total 9:30 AM Total 2:00 PM Total 1:00 PM Total
29 Time Out 0:00 12:00 PM 2:00 12:00 PM 2:30 3:30 PM 1:30 3:30 PM 2:30
30 7-L 7-L 7-L KAS
31 Time In Total 1:00 PM Total 1:00 PM Total 3:30 PM Total 3:30 PM Total
32 Time Out 0:00 2:00 PM 1:00 2:00 PM 1:00 5:00 PM 1:30 5:00 PM 1:30
33 KAS KAS
34 Time In Total 2:00 PM Total 2:00 PM Total Total Total
35 Time Out 0:00 5:00 PM 3:00 4:40 PM 2:40 0:00 0:00
36 Total
37 KAS 7-L
38 22:10 9:50
Sheet8

Worksheet Formulas
Cell Formula
D38 =SUMIF(\$E\$24:\$K\$34,D37,\$F\$26:\$L\$36)
F38 =SUMIF(\$E\$24:\$K\$34,F37,\$F\$26:\$L\$36)

Also, note that merged cells can be really bad. Formulas often don't play nice with them. Using "Center across selection" is often better.