+ Reply to Thread
Results 1 to 12 of 12

Hourly Headcount Calculator

  1. #1
    Registered User
    Join Date
    02-22-2024
    Location
    usa
    MS-Off Ver
    2019 MSO
    Posts
    6

    Question Hourly Headcount Calculator

    I am looking to create a dynamic schedule forecaster that will allow me to play with various models and move employees staffed days and hours around and have a table that updates automatically showing how many resources would be staffed at that given day/hour.

    Using the attached doc as a sample, i am looking for how to formulate the formula for J3:P26 to count the amount of resources who will work any given hour on any given day, based on the info in column B, C and D. If i have to spell out each day in column B i am open to that as well (example, changing "Mon-Fri" to "Mon, Tue, Wed, Thur, Fri").


    Staffing.xlsx
    Last edited by rsmith89; 02-27-2024 at 09:36 PM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Headcount Heatmap

    You have used proper (excel) time in column I but not in C and D, what makes the forrmula much longer.
    in J2 and copy right and down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    02-22-2024
    Location
    usa
    MS-Off Ver
    2019 MSO
    Posts
    6

    Re: Headcount Heatmap

    Thank you for the assistance Kaper! I see in your attachment that your formula works, but when i attempt to use it, it errors out and i get the #VALUE! response back. Even if i just select one of your cells and click on the formula and hit ENTER, it breaks the formula.

    Im assuming its due to some default settings in my Excel, but cant figure out how to prevent that. I have a few employees to add to the list and im trying to expand the references to the data in B,C, and D rows 2-6, but i cant figure out how to prevent it from breaking the formula.

    Also, if it makes it easier, i am open to changing Columns C & D to proper time if it helps shorten up the formula needed to calculate J2:P26.

    Thanks again!

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,864

    Re: Hourly Headcount Calculator

    I believe the issue here is that for the 2019 version of Excel the formula will need to be array entered.
    1. Select a cell in Kaper's file
    2. Press the F2 key to put that cell in edit mode
    3. Press and hold the Ctrl and Shift keys while pressing the Enter key
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Registered User
    Join Date
    02-22-2024
    Location
    usa
    MS-Off Ver
    2019 MSO
    Posts
    6

    Hourly Headcount Calculator

    Hello all,

    I am trying to document all the individual dates & times the various resources in my team work. Since we are 24x7, there are people working at any given hour on any given day. I need assistance in creating a formula to track how many resources would be on shift at any given hour on any given day.

    I am completely open to changing the formatting of this data if it makes generating the formula any easier. At the end of the day, all i need to see is:
    • Employee Name
    • Days Staffed
    • Shift Start Time
    • Shift End Time
    • Updated table on the right counting all the resources working each hour each day (J3:P26)


    Thank you everyone for your assistance, and please let me know if there are any questions!

    Attachment 863996
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,864

    Re: Hourly Headcount Calculator

    This proposal changes the source data and converts it into an Excel table so that the formulas in columns J:P will update automatically as new data is added.
    The changed data is highlighted amber.
    The formula used to populate columns J:P borrows on the one Kaper provided:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that for the 2019 version of Excel the formula will need to be array entered as described in post #4.
    Let us know if you have any questions.
    Attached Files Attached Files

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: Hourly Headcount Calculator

    In the case of overnight work, how is it calculated?
    For example:
    Employee U, from Wednesday to Sunday, from 9 PM to 6 AM, counting at 3 AM.
    Is the calculation as follows?
    From Wednesday 9 PM to Thursday 6 AM, count 1 at 3 AM on Thursday.
    From Thursday 9 PM to Friday 6 AM, count 1 at 3 AM on Friday.
    ...
    From Sunday 9 PM to Monday 6 AM, count 1 at 3 AM on Monday.
    The total count for Employee E is 5.
    Is it true? what is your expectation?
    Quang PT

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: Hourly Headcount Calculator

    With assumption in #7, below is the VBA solution.

    PHP Code: 
    Option Explicit
    Sub Staft
    ()
    Dim lr&, i&, j&, t&, p1&, p2&, rngres(), cell As Rangehr As Datewday$, wk$, wk2$, As Boolean
    Dim staH 
    As DateendH As Date
    rng 
    Sheets("Data").Range("A3").CurrentRegion.Value
    Sheets
    ("Output").Activate
    wk 
    "MonTueWedThuFriSatSunMonTueWedThuFriSat"
    Range("B2:H25").ClearContents
    For Each cell In Range("B2:H25")
        
    hr Cells(cell.Row"A").Value
        wday 
    Cells(1cell.Column).Value
        
    For 3 To UBound(rng)
            
    p1 InStr(1wkrng(i2))
            
    p2 InStr(p1wkrng(i3))
            
    wk2 Mid(wkp1p2 p1 3)
            
    False
            
    If rng(i5) < rng(i4Then
                c 
    True
                endH 
    TimeSerial(2300)
            Else
                
    endH rng(i5)
            
    End If
            If 
    InStr(1wk2wdayThen
                
    If hr >= rng(i4) And hr <= endH Then cell.Value cell.Value 1
            End 
    If
            If 
    c Then
                wk2 
    Mid(wkp1 3p2 p1 3)
                
    wday Mid(wkInStr(1wkwday) + 33)
                If 
    InStr(1wk2wdayThen
                    
    If hr <= rng(i5Then cell.Value cell.Value 1
                End 
    If
            
    End If
        
    Next
    Next
    End Sub 
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    02-22-2024
    Location
    usa
    MS-Off Ver
    2019 MSO
    Posts
    6

    Re: Hourly Headcount Calculator

    Quote Originally Posted by bebo021999 View Post
    In the case of overnight work, how is it calculated?
    For example:
    Employee U, from Wednesday to Sunday, from 9 PM to 6 AM, counting at 3 AM.
    Is the calculation as follows?
    From Wednesday 9 PM to Thursday 6 AM, count 1 at 3 AM on Thursday.
    From Thursday 9 PM to Friday 6 AM, count 1 at 3 AM on Friday.
    ...
    From Sunday 9 PM to Monday 6 AM, count 1 at 3 AM on Monday.
    The total count for Employee E is 5.
    Is it true? what is your expectation?

    Yes that is exactly correct.

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: Hourly Headcount Calculator

    So, does the code in #8 work?

  11. #11
    Registered User
    Join Date
    02-22-2024
    Location
    usa
    MS-Off Ver
    2019 MSO
    Posts
    6

    Re: Hourly Headcount Calculator

    i apologize for the delayed response, but i finally had time to validate the code. Everything looks like its working properly, with one exception.

    The end of each shift is counting an extra hour than it should be. For example 8am - 5pm would only add a count in the 8am-4pm rows, as that resource would be getting off work at 5pm, and would not be present for the 5pm-6pm slot. Currently the code is adding a count for 8am, 9am, 10am, 11am, 12pm, 1pm, 2pm 3pm, 4pm, and 5pm, where it should add its last tick in the 4pm row as that would signify "4pm-5pm".

    I dont see an easy place to edit the code built as i dont see where the start/end times of shifts are referenced to try and add a "-1" to the shift end.

  12. #12
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,864

    Re: Hourly Headcount Calculator

    I imagine that you are responding to bebo, however I will put this here anyway.
    In order to accomplish the request in post #11, the array entered formula** from post #6 may be modified to read:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ** See post #4 item 3.
    Let us know if you have any questions.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Heatmap color scaling, color cell based on cell value
    By Komarov in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-17-2021, 05:11 AM
  2. Heatmap/dates help!
    By obriej in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-28-2020, 08:41 AM
  3. Replies: 1
    Last Post: 07-17-2013, 11:34 AM
  4. Heatmap
    By batchy in forum Excel General
    Replies: 3
    Last Post: 04-26-2012, 09:28 AM
  5. Heatmap Chart
    By matthew.edwards in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-19-2011, 05:29 AM
  6. Heatmap Graph
    By matthew.edwards in forum Excel General
    Replies: 0
    Last Post: 10-18-2011, 10:48 AM
  7. building Heatmap
    By excelhelp18 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-31-2010, 10:38 AM

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