+ Reply to Thread
Results 1 to 30 of 30

Count employees working hourly

Hybrid View

  1. #1
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Count employees working hourly

    The code below will insert new lines if col B contains 2 time entries, and then will also update columns C to AI as well (the j loop does this)

    As AliGW pointed out, your formulas for counts do require that the names be present in column A.
    Sub test()
    
    Dim ws As Worksheet
    Dim lr As Long
    Dim i As Long
    Dim j As Long
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    
    Set ws = Worksheets("Sheet1") 'change as needed to the name of the sheet with time info
    
    lr = ws.Range("A" & Rows.Count).End(xlUp).Row
    For i = lr To 3 Step -1 'the 3 in this line is the first row with employee data, change as needed
        If UBound(Split(ws.Range("B" & i).Value, Chr(10))) > 0 Then
            ws.Range("B" & i + 1).EntireRow.Insert shift:=xlDown, copyorigin:=xlfromabove
            ws.Range("B" & i).EntireRow.Copy ws.Range("A" & i + 1)
            ws.Range("B" & i).Value = Split(ws.Range("B" & i).Value, Chr(10))(0)
            ws.Range("B" & i + 1).Value = Split(ws.Range("B" & i + 1).Value, Chr(10))(1)
            For j = 3 To 35 'loops through columns C to AI to split multiple times in cell
                If UBound(Split(ws.Cells(i, j).Value, Chr(10))) > 0 Then
                    ws.Cells(i, j).Value = Split(ws.Cells(i, j).Value, Chr(10))(0)
                    ws.Cells(i + 1, j).Value = Split(ws.Cells(i + 1, j).Value, Chr(10))(1)
                End If
            Next j
        End If
    Next i
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
    
    End Sub
    Last edited by Arkadi; 07-19-2017 at 08:38 AM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

+ 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. Count Employees Working in Half Hour Intervals
    By shanewfm in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-24-2015, 01:12 PM
  2. [SOLVED] Count the number of employees working per hour
    By esmith#001 in forum Excel Formulas & Functions
    Replies: 27
    Last Post: 12-04-2014, 07:46 AM
  3. Using Punchclock data to count employees working during each hour
    By ellenowski in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-13-2014, 10:22 AM
  4. Working out Various Hourly Rate : TImesheet
    By fgbuk in forum Excel General
    Replies: 2
    Last Post: 07-23-2011, 03:51 PM
  5. Excel 2007 : Employees working day
    By reetu in forum Excel General
    Replies: 12
    Last Post: 01-07-2011, 03:57 PM
  6. Sumproduct-not all employees are working
    By Debs1 in forum Excel General
    Replies: 10
    Last Post: 11-27-2009, 12:44 PM
  7. [SOLVED] Number of employees working at given time
    By Scott in forum Excel General
    Replies: 1
    Last Post: 12-28-2005, 08:30 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