SUM based on conditional formating

lifeonathread

New Member
Joined
Oct 5, 2010
Messages
12
Hello!
I'm having trouble with writing a formula properly. I may be using the wrong type of formula to get the result I need.
The basic idea is this:
I'm trying to determine how many shifts were worked on high-incident days for each employee.
The basic format of the sheet is thus:



Column A Date

Column B Opening Dollar Amount
Column C Closing Dollar Amount
Column E Individual Employee Attendance (marked as 1, for attended, blank for not attended)
I currently have conditional formatting applied so that if the value of B or C is greater than 5, or less than -5, then the row is highlighted yellow.
OR($B6<-5,$B6>5,$C6<-5,$C6>5)
This part works great!
However, I need a sum of the attendance marks in E which also fit the criteria of the conditional formatting, since as I understand it, the program can't tell the cell has been colored since I used conditional formatting to do so.
This is the formula I came up with:
=SUMIF($B6:$C40, AND(OR($B6<-5,$B6>5,$C6<-5,$C6>5), $E6>0), E6:E40)
However, the returned value is 0, but I know the correct value should be 9.

In another forum I received the following formula from a kind poster, and plugged it in and it appeared to work.
=SUMPRODUCT(($E$6:$E$36),(($B$6:$B$36<-5)+($B$6:$B$36>5)+($C$6:$C$36<-5)+($C$6:$C$36>5)))
However, after adding a few rows to the sheet and adjusting the ranges so that they corresponded I soon came to realize that what the formula was giving me was NOT the correct answers. It was adding items outside those permitters and in most cases was off by one or two. Perhaps there was something I did wrong in my editing? This is my "corrected" formula based on the new range.
=SUMPRODUCT(($E$9:$E$40),(($B$9:$B$40<-5)+($B$9:$B$40>5)+($C$9:$C$40<-5)+($C$9:$C$40>5)))
However the formula is returning 15 for Jim when a manual count of highlighted incidents is only 13.

Any and all help is greatly appreciated!

COPY OF THE WORKING FILE:
https://www.dropbox.com/s/cdoo5epyqu9udsh/WorksheetUPDATED.xlsx?dl=0
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
To avoid a double counting you should test if the sum of the conditions is greater than 0 (zero)

So, for Jim, try this
=SUMPRODUCT(($E$9:$E$40),--((($B$9:$B$40<-5)+($B$9:$B$40>5)+($C$9:$C$40<-5)+($C$9:$C$40>5))>0))

Hope this helps

M.
 
Upvote 0
To avoid a double counting you should test if the sum of the conditions is greater than 0 (zero)

So, for Jim, try this
=SUMPRODUCT(($E$9:$E$40),--((($B$9:$B$40<-5)+($B$9:$B$40>5)+($C$9:$C$40<-5)+($C$9:$C$40>5))>0))

Hope this helps

M.

That fixed the issue! Thank you so much!!
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

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