Results 1 to 18 of 18

Count Consecutive Days while bridging over days off and holidays

Threaded View

  1. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Count Consecutive Days while bridging over days off and holidays

    I have written a simple User Defined Function (UDF) called CONSEQOFF() that you can install into our workbooks as needed and it will provide the new count function you need.
    Option Explicit
    
    Function CONSEQOFF(Workdays As Range) As Long
    Dim Cnt As Long, cell As Range
    
    For Each cell In Workdays
        Select Case cell.Value
            Case Is = ""
                CONSEQOFF = WorksheetFunction.Max(CONSEQOFF, Cnt)
                Cnt = 0
            Case Is = "MIA", "MIAOUT", "UPTO"
                Cnt = Cnt + 1
            Case Is = "HOLOFF", "DAYOFF"
                'skip, do nothing
        End Select
    Next cell
    CONSEQOFF = WorksheetFunction.Max(CONSEQOFF, Cnt)
    
    End Function
    After it installed, it is used in a cell like any other function.

    =CONSEQOFF(Workdays)

    Workdays = the range of cells you want to evaluate


    =========
    How to install the User Defined Function:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    The function is installed and ready to use.
    Attached Files Attached Files
    Last edited by JBeaucaire; 08-04-2015 at 06:27 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Count 6 working days (excluding Sunday, Holidays & half days)
    By eve_star1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-29-2015, 08:00 AM
  2. Replies: 0
    Last Post: 10-31-2014, 10:32 AM
  3. Replies: 4
    Last Post: 05-19-2014, 04:28 PM
  4. Count Working days by subtracting bank holidays and weekends
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2014, 07:40 AM
  5. Count Days EXCLUDING ONLY Sundays and a named range for Holidays
    By Seaplane Jack in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-14-2014, 05:03 PM
  6. Employee Time Tracking - Sick days & Consecutive Days
    By notaguru6 in forum Excel General
    Replies: 6
    Last Post: 08-09-2013, 12:50 PM
  7. [SOLVED] How do you count work days excluding weekends and holidays?
    By Hausma in forum Excel General
    Replies: 2
    Last Post: 04-08-2005, 03:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1