Results 1 to 20 of 26

Thread: Calculating Working hours in a Week

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,877
    Location
    This is a bit brute force

    Sub test()
        MsgBox WorkingHours(#6/1/2011#)
    End Sub
    
    Function WorkingHours(MonthYear As Date) As Double
        Dim i As Long
        Dim N As Double
        N = 0#
        For i = DateSerial(Year(MonthYear), Month(MonthYear), 1) To DateSerial(Year(MonthYear), Month(MonthYear) + 1, 0)
            Select Case Weekday(i)
                Case vbMonday, vbTuesday, vbThursday
                    N = N + 8
                Case vbWednesday
                    N = N + 4
                Case vbFriday
                    N = N + 5
            End Select
        Next i
        WorkingHours = N
    End Function
    Paul
    Last edited by Aussiebear; 06-29-2024 at 01:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •