Hello,
I am creating a template for another team to track the time it takes to handle a case. This VBA macro is being added to a button for that individual to press to calculate the time.
Here's what I have,
Cell B2 has a starting date & time in this format "3/31/17 3:40 PM", cell E2 has an end date & time "4/12/17 12:15 PM". I am wanting to calculate the amount of hours passed from start to end excluding weekends and holidays
Here is the code I started with:
This is the type of result I am looking for minus weekends and holidays. I tried to use "worksheetfunction.networkdays" but that only told me how many days had passed excluding weekends and holidays, and did not take into account the time the case was started. I guess I am looking to put these two codes together but not sure how to do it.
I am creating a template for another team to track the time it takes to handle a case. This VBA macro is being added to a button for that individual to press to calculate the time.
Here's what I have,
Cell B2 has a starting date & time in this format "3/31/17 3:40 PM", cell E2 has an end date & time "4/12/17 12:15 PM". I am wanting to calculate the amount of hours passed from start to end excluding weekends and holidays
Here is the code I started with:
Code:
Private Sub CommandButton2_Click()
Dim wb As Workbook
Dim wks As Worksheet
Dim wksLR As Long, row As Long
Set wb = ThisWorkbook
Set wks = wb.Sheets("2017 Formulary Box Issue Log")
wksLR = wks.Cells(wks.Rows.Count, 1).End(xlUp).row
With wks
For row = 2 To wksLR
On Error Resume Next
.Cells(row + 1, 7) = Format(((.Cells(row + 1, 5) - .Cells(row + 1, 2)) * 24), "#.00")
Next row
End With
Set wks = Nothing
Set wb = Nothing
End Sub
This is the type of result I am looking for minus weekends and holidays. I tried to use "worksheetfunction.networkdays" but that only told me how many days had passed excluding weekends and holidays, and did not take into account the time the case was started. I guess I am looking to put these two codes together but not sure how to do it.