Skipping Days Off

dkidroske

New Member
Joined
Oct 3, 2008
Messages
25
I am measured by how fast I can move equipment from the time it is received until the time I start processing it and the time I ship it. Equipment comes in every day of the week, but I don't have to start the clock on weekends or holidays until the first workday following its arrival.

My db creates a record when the equipment is checked in.

I used DATEDIF to compare the date received to the date processed and the ship date. However, I have to manually move weekend dates and holidays to the next work date.

Is there a way to create a formula to do this?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi,

Have you looked at 'Networkdays'? that might be a solution for you.

Mel
 
Upvote 0
If you don't mind using VBA try this...

This needs to go on the worksheet's code page:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 
Dim myDate As Date
' Check which column change has been made to
' If not within required column then exit sub
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
' If more than one cell is changed at any one time then exit sub
If Target.Count > 1 Then Exit Sub
' Check if data entered into target cell is a date
If IsDate(Target.Value) Then
' Populate myDate variable with date
    myDate = Target.Value
 
' Check if the date is a weekend or bank holiday and
' move forward a day if so until a non-bank holiday weekday
 
    Do While check_WE(myDate) = True Or check_BH(myDate) = True
 
    myDate = myDate + 1
7
    Loop
' Populate required cell with date held in myDate variable
    Target.Offset(0, 1).Value = myDate
End If
End Sub

It will check the date entered in Column A and put a date adjusted for weekends and holidays in Column B.

You will also need to add a module to the workbook's VBA project and pop these onto it:

Code:
Public Function check_BH(check_date As Date) As Boolean
 
Dim c As Range
' Check if date passed is in the named range BH_Dates and return
' true or false accordingly
With Range("BH_Dates")
 
    Set c = .Find(check_date, LookIn:=xlValues)
 
    If c Is Nothing Then
 
        check_BH = False
 
    Else
 
        check_BH = True
 
    End If
 
End With
 
End Function
 
 
Public Function check_WE(check_date As Date) As Boolean
' Check if date passed is either Sat or Sun and return
' true or false accordingly
 
If Weekday(check_date, vbMonday) > 5 Then
 
    check_WE = True
 
Else
 
    check_WE = False
 
End If
 
End Function

Last but not least you will need to create a list of holiday dates on a spare worksheet and give it the defined name of BH_Dates.

Hope it helps,

Dom
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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