Help with a function/formula

julievandermeulen

Board Regular
Joined
Jan 25, 2020
Messages
107
Office Version
  1. 365
Platform
  1. Windows
I need help writing a function/formula


in tab Sheet 3
in cell D7
I want it to subtract .5 if there is a "x" in Cells A2:A5 but I can't figure it out.
 
Try
Excel Formula:
=IF(COUNTIF(A2:A5,"x"),SUM(D2:D5)-0.5,SUM(D2:D5))

but can there be more than 1 "x"
 
Upvote 0
Try
Excel Formula:
=IF(COUNTIF(A2:A5,"x"),SUM(D2:D5)-0.5,SUM(D2:D5))

but can there be more than 1 "x"
Try
Excel Formula:
=IF(COUNTIF(A2:A5,"x"),SUM(D2:D5)-0.5,SUM(D2:D5))

but can there be more than 1 "x"
Awesome. Is there a way to calculate it by row and the information in column f.
For example. if cells A2:a5 has an "x" the subtract .5 from the row the x is in. and also calculate columns b & c depending on if there is an "s" in column f.
F2 & F3 have a "S" so B2:c3 = 3:00 and because A3 has a "x" it should be 2.50

 
Upvote 0
Not sure what you need for new "s" in column F, but try:

In D2 then drag down
Code:
=SUM(C2-B2)*24-(A2="x")*(F2="s")*0.5
 
Upvote 0
I needed to change this to categorize things better. If I use sumproduct I can get part of what I'm looking for but I need to subtract .5 from the total for the category type of the row that the "x" is in. I can't figure out how to write the formula.


 
Upvote 0
Calender formation for Excel 365 version.xlsx
ABCDEFG
1lunchtime intime outtotal time
208:0009:001s
3x09:0011:002s
411:0011:300.5r
511:3012:000.5b
6Total
7r0.5
8s2.5
9b0.5
10grand total3.5
11
Sheet4
Cell Formulas
RangeFormula
D7:D9D7=SUMPRODUCT(($F$2:$F$5=$C7)*((($C$2:$C$5-$B$2:$B$5)*24)-(($A$2:$A$5="x")*0.5)))

In D7 copied down.
Excel Formula:
=SUMPRODUCT(($F$2:$F$5=$C7)*((($C$2:$C$5-$B$2:$B$5)*24)-(($A$2:$A$5="x")*0.5)))
 
Upvote 0
Solution
Calender formation for Excel 365 version.xlsx
ABCDEFG
1lunchtime intime outtotal time
208:0009:001s
3x09:0011:002s
411:0011:300.5r
511:3012:000.5b
6Total
7r0.5
8s2.5
9b0.5
10grand total3.5
11
Sheet4
Cell Formulas
RangeFormula
D7:D9D7=SUMPRODUCT(($F$2:$F$5=$C7)*((($C$2:$C$5-$B$2:$B$5)*24)-(($A$2:$A$5="x")*0.5)))

In D7 copied down.
Excel Formula:
=SUMPRODUCT(($F$2:$F$5=$C7)*((($C$2:$C$5-$B$2:$B$5)*24)-(($A$2:$A$5="x")*0.5)))
Awesome! Thanks so much!!
 
Upvote 0
A few comments. Since you have Microsoft 365 you don't need the relatively inefficient SUMPRODUCT as the more efficient SUM will work for you here. Your version also allows to calculate all the results, including the grand total, with a single formula. That is, no need to copy it down.
You can also do without all the $ signs in that case and there is some unnecessary parentheses in the current formula.

25 03 29.xlsm
ABCDEF
1lunchtime intime outtotal time
208:0009:001s
3x09:0011:002s
411:0011:300.5r
511:3012:000.5b
6Total
7r0.5
8s2.5
9b0.5
10grand total3.5
Sheet3
Cell Formulas
RangeFormula
D7:D10D7=LET(v,BYROW(C7:C9,LAMBDA(rw,SUM((F2:F5=rw)*((C2:C5-B2:B5)*24-(A2:A5="x")*0.5)))),VSTACK(v,SUM(v)))
Dynamic array formulas.
 
Upvote 0

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