Total all cells containing specific text in two cells

suxrule

New Member
Joined
Mar 2, 2021
Messages
14
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
Hi, hope someone can help.

I'm looking to get the J column to work out the total for days and nights for each department.

So far I have

=COUNTIFS(C4:C11,"*DAYS*",D4:D11,"*Dept 1*")>0

But I can only get to TRUE or False but it to obviously add each instance together.

Hope that makes sense...with my attached mini sheet.

Thanks

Student Returners.xlsm
ABCDEFGHIJK
1Table I will be pulling data fromDepartment Total (days and night added together)This is as far as I got…Formula needed here?Need the result to equal the below
2
3NameTotal HoursDays or NightsDepartmentDept 115DaysTRUE?7.5
417.5DaysDept 1NightsTRUE?7.5
527.5NightsDept 1
637.5DaysDept 2Dept 27.5DaysTRUE?7.5
747.5NightsDept 3NightsFALSE?0
857.5NightsDept 3
967.5DaysDept 4Dept 315DaysFALSE?0
1067.5NightsDept 4NightsTRUE?15
1167.5DaysDept 4
12Dept 422.5DaysTRUE?15
13NightsTRUE?7.5
Test
Cell Formulas
RangeFormula
G3G3=SUMIF(D4:D11,"*"&F3&"*",B4:B11)
I3I3=COUNTIFS(C4:C11,"*DAYS*",D4:D11,"*Dept 1*")>0
I4I4=COUNTIFS(C4:C11,"*NIGHTS*",D4:D11,"*Dept 1*")>0
G6G6=SUMIF(D4:D11,"*"&F6&"*",B4:B11)
I6I6=COUNTIFS(C4:C11,"*DAYS*",D4:D11,"*Dept 2*")>0
I7I7=COUNTIFS(C4:C11,"*NIGHTS*",D4:D11,"*Dept 2*")>0
G9G9=SUMIF(D4:D11,"*"&F9&"*",B4:B11)
I9I9=COUNTIFS(C4:C11,"*DAYS*",D4:D11,"*Dept 3*")>0
I10I10=COUNTIFS(C4:C11,"*NIGHTS*",D4:D11,"*Dept 3*")>0
G12G12=SUMIF(D4:D11,"*"&F12&"*",B4:B11)
I12I12=COUNTIFS(C4:C11,"*DAYS*",D4:D11,"*Dept 4*")>0
I13I13=COUNTIFS(C4:C11,"*NIGHTS*",D4:D11,"*Dept 4*")>0
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Just remove the >0 from the end of the formula
 
Upvote 0
Thanks.

Sorry I've probably not explained myself very well.

I want any time "Days" or "Nights" is mentioned with the correct department I want the hours associated with each department added to either the days or nights adjacent cells in the red highlighted cells in my example above.

Thanks again though.
 
Upvote 0
Ok, you need to use sumifs in that case like
Excel Formula:
=SUMIFS(B4:B11,C4:C11,"*DAYS*",D4:D11,"*Dept 1*")
 
Upvote 0
Solution
Excellent, thanks so much, really appreciate it.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,180
Members
448,871
Latest member
hengshankouniuniu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top