HOW TO GET WORKED HRS FOR SPECIFIC PERIOD

gssachin

Board Regular
Joined
Nov 14, 2013
Messages
155
Hi,



I want to count attendance for a specific period.



I have a 1000 employee’s timesheet. Column “C” to column “AG” for 31 days of May and specific period enter in column “AH” & “AI” i.e. start date & end date



I received attendance in text format to I use to the following formula (in cell “AJ” to get full month attendance.



=(COUNTIF($C$2:$AG$2,"8")*8)+(COUNTIF($C$2:$AG$2,"6")*8)+(COUNTIF($C$2:$AG$2,"5")*5)+(COUNTIF($C$2:$AG$2,"3")*3)



But I need to get attendance for the Specific period only…


Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJ
1EMP NONAME0102######0910111213141516171819202122232425262728293031START DATEEND DATEWORKED HRS
2100ABCWO6666666WO66666WO6666666WOHHHOOWOOO10/05/202026/05/202096
3101CDE6WO666666WO666666WO666666WOHHH888WO801/05/202031/05/2020184
Sheet1
Cell Formulas
RangeFormula
AJ3AJ3=(COUNTIF($C$3:$AG$3,"8")*8)+(COUNTIF($C$3:$AG$3,"6")*8)+(COUNTIF($C$3:$AG$3,"5")*5)+(COUNTIF($C$3:$AG$3,"3")*3)




Any suggestion/help…..
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this in J2

edit:- Simpler version, this didn't work when I first tried it, must have had a typo :oops:

=SUMPRODUCT(COUNTIFS($C$1:$AG$1,">="&AH2,$C$1:$AG$1,"<="&AI2,C2:AG2,{8,6,5,3}),{8,8,5,3})
 
Last edited:
Upvote 0
Try this in J2

edit:- Simpler version, this didn't work when I first tried it, must have had a typo :oops:

=SUMPRODUCT(COUNTIFS($C$1:$AG$1,">="&AH2,$C$1:$AG$1,"<="&AI2,C2:AG2,{8,6,5,3}),{8,8,5,3})
its work for me.... thanks a lot :)
 
Upvote 0
Hi,

One more help needed if the cell has more than 8 hrs then it should count as 8 hrs Only
 
Upvote 0
Try this, array confirmed with Ctrl Shift Enter.
Excel Formula:
=SUMPRODUCT(IFERROR(($C$1:$AG$1>=AH2)*($C$1:$AG$1<=AI2)*TEXT(C2:AG2,"[>=6]\8;[<6]0"),0))
Note that if the formula displays #VALUE! or 0 when a result is expected then it would most likely mean that the array has not been confirmed correctly.
 
Upvote 0
Good Morning,

The above formula works for me :) but in that formula, I cant specify some text consider as 8 hrs (i.e. if an employee has "SL" - sick leave then it should consider 8 hrs and add it to the total hrs.

Is it possible.....
 
Upvote 0
Is it only "SL" that needs to be added to the total or are there other text codes to consider as well?
If there are, what are they and what are the hours for each?
 
Upvote 0
No, it's not only "SL", it's changing from time to time like NGP (No gate pass), CR (Due to Corona Leave), ML (Medical leave) it may add a few more.
So like in the 1st formula where we can add text and give how many hrs to add like that I needed.
 
Upvote 0
Untested
Excel Formula:
=SUMPRODUCT(IFERROR(($C$1:$AG$1>=AH2)*($C$1:$AG$1<=AI2)*TEXT(SUBSTITUTE(C2:AG2,"SL",8),"[>=6]\8;[<6]0"),0))
Don't forget to array confirm it the same as before.
Here's an example with a second text code so that you can see how to add more if you need to.
Excel Formula:
=SUMPRODUCT(IFERROR(($C$1:$AG$1>=AH2)*($C$1:$AG$1<=AI2)*TEXT(SUBSTITUTE(SUBSTITUTE(C2:AG2,"NGP",8),"SL",8),"[>=6]\8;[<6]0"),0))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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