Sumifs Help - Payroll Planning

acctmn

New Member
Joined
Aug 23, 2018
Messages
1
See the table below, I'm looking to calculate available hours in Col D.

the SUMIF statements for the FT and PT statuses are straightforward. Looking for help on the date conditional in regards to 'Seas' Status.

If the status is 'Seas' I want their Hrs Avl added to the total Available hours based on their Avl Date and End Date.

If I need to convert the Avl/End Date in Col I and J to match the dates in A and C to make the formula simpler that can be done.

First time post, sorry if this isn't how it's supposed to work or is missing info.



Available HoursNameStatusAv. HrsAvl DateEnd Date
12/31/2018-1/6/2019JoeFT
1/7/2019-1/13/2019MikePT25
1/14/2019-1/20/2019SteveFT
1/21/2019-1/27/2019BillSeas401/5/20192/5/2019
1/28/2019-2/3/2019MarySeas302/1/20193/1/2019
2/4/2019-2/10/2019AshleyPT15
2/11/2019-2/17/2019
2/18/2019-2/24/2019
2/25/2019-3/3/2019
3/4/2019-3/10/2019

<tbody>
</tbody>
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
.
This is one method :

Paste this macro into a Routine Module :

Code:
Option Explicit


Function Work_Days(BegDate As Variant, EndDate As Variant) As Integer
 
 Dim WholeWeeks As Variant
 Dim DateCnt As Variant
 Dim EndDays As Integer
 
 On Error GoTo Err_Work_Days
 
 BegDate = DateValue(BegDate)
 EndDate = DateValue(EndDate)
 WholeWeeks = DateDiff("w", BegDate, EndDate)
 DateCnt = DateAdd("ww", WholeWeeks, BegDate)
 EndDays = 0
 
 Do While DateCnt <= EndDate
 If Format(DateCnt, "ddd") <> "Sun" And _
 Format(DateCnt, "ddd") <> "Sat" Then
 EndDays = EndDays + 1
 End If
 DateCnt = DateAdd("d", 1, DateCnt)
 Loop
 
 Work_Days = WholeWeeks * 5 + EndDays
 
Exit Function
 
Err_Work_Days:
 
 ' If either BegDate or EndDate is Null, return a zero
 ' to indicate that no workdays passed between the two dates.
 
 If Err.Number = 94 Then
 Work_Days = 0
 Exit Function
 Else
' If some other error occurs, provide a message.
 MsgBox "Error " & Err.Number & ": " & Err.Description
 End If
 
End Function

Format COL D as NUMBER / 2 places decimal

Paste this formula in D3 and drag down : =IF(E3<>"",(H3/8)*E3,"")

Paste this formula in E3 and drag down : =IF(G3="Seas",Work_Days(I3,J3),"")



Download example workbook : https://www.amazon.com/clouddrive/share/ve8xGrV8kUgHcBUYAf3NFMhW903qLSELoBNMZSJNYG7
 
Upvote 0
.
Also keep in mind the solution considers a work day as Mon - Fri and does not account for holidays during those days.

A solution to including holidays can be seen here : https://exceljet.net/formula/get-workdays-between-dates

using this formula (and removing the macro FUNCTION) : =Networkdays(start_date,end_date,holidays)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,970
Members
448,933
Latest member
Bluedbw

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