HOW TO GET WORKED HRS FOR SPECIFIC PERIOD

gssachin

Board Regular
Joined
Nov 14, 2013
Messages
131
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…..
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,488
Office Version
  1. 365
Platform
  1. Windows
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:

gssachin

Board Regular
Joined
Nov 14, 2013
Messages
131
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 :)
 

gssachin

Board Regular
Joined
Nov 14, 2013
Messages
131
Hi,

One more help needed if the cell has more than 8 hrs then it should count as 8 hrs Only
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,488
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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.
 

gssachin

Board Regular
Joined
Nov 14, 2013
Messages
131
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.....
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,488
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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?
 

gssachin

Board Regular
Joined
Nov 14, 2013
Messages
131
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.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,488
Office Version
  1. 365
Platform
  1. Windows
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))
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,118,413
Messages
5,571,964
Members
412,429
Latest member
brahmaiah
Top