Add hours together using VBA - excel

I have an excel sheet that displays the total number of regular hours and overtime hours in excel. I am trying to figure out how to add them together to get a Total hours worked in a month the excel sheet looks like the following
E00XXXX James Smith 160:00 19:52
E00XXXX John Doe 160:00 19:52
E00XXXX Sue Patterson 160:00 19:52
I am trying to add the last two columns together to get something like this
E00XXXX James Smith 160:00 19:52 179:52
E00XXXX John Doe 160:00 15:22 175:22
E00XXXX Sue Patterson 160:00 10:47 170:47
I don't have any code to try, because I honestly don't even know where to start. I would also like to state that this has to be done within a VBA and that I do not have control over the format in excel.

To automatically format times that when added together exceed 24 hours, 60 minutes, or 60 seconds, you can use the following custom number formats and the SUM function in Excel:
Hours = [h]:mm:ss
Minutes = [m]:ss
Seconds = [ss]
Source

Related

Count days worked per employee number in Excel

I have a timesheet entry form that people use to enter their hours worked per day. Sometimes they enter multiple entries per day because of different areas worked.
I want to count how many days worked based on the work date. There could be multiple entries per workdate.
For example:
Employee # Date Hours
12345 11/15/17 8
12345 11/16/17 4
12345 11/16/17 3
98765 11/15/17 2
98765 11/15/17 2
98765 11/15/17 2
I have a consolidated table that sums the hours worked per employee, but I also would like the days worked. So, for example:
Employee # Hours Days
12345 15 2
98765 6 1
I can't seem to put my finger on the right formula/combination of formulas to use. Countif would work perfectly if it worked similarly to sumif.
Maybe you can try Advanced Filter,then COUNTIF and SUMIF:
Hope this helps.

How do I add a unit suffix to the hours an employee has worked?

I'm looking for a formula to count hours and set up a shift plan
My idea is for managers, front of house and back of house to have their own planner.
Where I fall at is when I try to count hours for each staff member BUT also make it legible to the reader when printed
For example
Staff member 4 does
0830-1600 with an hour break on Monday
1200-1900 with no break on Tuesday
I want it to look like 0830-1600, but in the total hours to count out the whole week from the times put in each day
I think you need to re-design your calendar. Excel loves raw data to be split out onto separate rows so let's start with that.
This is my end goal - it's a simplified version of yours
Data
So let's set out the data that will get us there - in rows. For this example, paste the data into cell A6:
Name Day Time In Time Out Total
Name 1 09/01/17 08:00 18:00 10:00
Name 1 12/01/17 11:00 15:00 04:00
Name 1 13/01/17 12:00 21:00 09:00
Name 2 10/01/17 08:00 13:00 05:00
Name 2 11/01/17 12:00 20:00 08:00
Name 2 13/01/17 10:00 14:00 04:00
And then add another few columns onto the end which will be useful in getting totals and making the table more readable
Unique ID is created simply by concatenating name and day : =A7&B7. And the Time String uses the TEXT function
=UPPER(TEXT(C7,"hAM/PM")&"/"&TEXT(D7,"hAM/PM"))
Table
Create your table in A1:F3 (like below). No need for manual shift data but do put your people and dates headings in:
Use this simple formula in cell B2 and drag down and across to populate shift data
=IFERROR(VLOOKUP($A2&B$1,$F$6:$G$12,2,0),"OFF")
Similarly, you can use this formula for the total hours
=SUMIF($A$7:$A$12,$A2,$E$7:$E$12)*24
Result
The final result is below, and can be easily manipulated for more people/ dates, etc.
If you have questions about any of these formulas/ techniques -- do ask

Lookup with multiple criteria, one a MAX value

I am trying to lookup the LOCATION of an employee (NAME) and their MANAGER from the most recent month (largest month number) in a particular QUARTER in data like this:
NAME LOCATION MANAGER QUARTER MONTH
Ryan Smith Sioux Falls Rick James 3 7
Jane Doe Tampa Bobby Brown 3 7
John Rogers Tampa Tracy Lane 3 7
Ryan Smith Sioux Falls Rick James 3 8
Jane Doe Denver Thomas Craig 3 8
John Rogers Tampa Cody Davis 3 8
So if I know the name of the employee and the quarter I'm looking up, the results should display who their last manager was and the location they were in, as these may change month to month.
I have used an INDEX and MATCH array formula:
{=INDEX($B$2:$B$7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0))}
but this just provides the first match and not necessarily the most recent month in that quarter. I attempted to include a MAX function which looked something like this:
{=INDEX($B$2:$B$7,MAX($E2:$E7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0)))}
but that didn't quite get me there either.
What formula do I need to get this to work?
I think I'd choose a PivotTable for its versatility and speed:
I think a pivot table is probably the best option and can easily be modified with the filters when new entries are added to the underlying data. I was working on a solution with a formula, but it requires you to add a lookup column.
The formula for the lookup column is: =E6&" "&H6&" "&I6
I wasn't clear on how the OP was going to be "entering" his employee name and quarter, so I had to make an assumption that it would be in a separate column:
And the formula in column B (which is cumbersome) is:
=VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,3,FALSE)&", managed by "&VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,4,FALSE)
But it works, and as long as the lookup range is adjusted, is scaleable.

Count the number of absent in different sheet excel

I have 6 worksheets and each containing names of workers. The first sheet just picks data from the other five sheets each representing a week day. The other five sheets contains names of workers which is in a column A, their working hours in column B and column C is whether they are absent or not. I want a way to collect information to the first sheet such that there will be a column that will count the number of days a worker has being absent.
When a worker is absent it is marked "absent" else it is left blank.
Can I use it with VLOOKUP included?
You should be able to use a "=COUNTIFS(criteria_range1,criteria1,criteria_range2,criteria2,etc.)"
statement which might look something like: "=COUNTIFS(WorkerNameRange,WorkerName,AbsentColumn,AbsentIndicator)"
or
"=COUNTIFS(ColumnA,WorkerName,ColumnC,AbsentIndicator)"
Okay, you didn't provide a lot of information, so here is my best answer based off of some made up sample data.
We will use 3 workers, George, Bob, and Steve. George works 8 hours/day, Bob 6 hours/day, and Steve 4 hours/day. So this is what I assume the Monday sheet would look like
Monday
Bob and Steve both missed work (rough weekend), so we won't count their hours on the Total sheet. We will also count this as 1 absent for both.
Worker Hours Absent
George 8
Bob 6 absent
Steve 4 absent
Tuesday
Tuesday is similar to Monday except that only Steve was absent.
Worker Hours Absent
George 8
Bob 6
Steve 4 absent
Total Sheet
We will assume that no one was absent for the rest of the week. So George should have gotten in 40 hours with 0 days absent. Bob missed a day, so he only got in 4*6=24 hours. Steve missed two days, so his hours will be 3*4=12. Bob will have 1 absent and Steve will have 2.
Worker Hours Days Absent
George 40 0
Bob 24 1
Steve 12 2
To sum up the hours they were present, we can use the following formula in the Hours column on the Total sheet.
=SUMIFS(Monday!$B$2:$B$4,Monday!$A$2:$A$4,Total!A2,Monday!$C$2:$C$4,"")+SUMIFS(Tuesday!$B$2:$B$4,Tuesday!$A$2:$A$4,Total!A2,Tuesday!$C$2:$C$4,"")+SUMIFS(Wednesday!$B$2:$B$4,Wednesday!$A$2:$A$4,Total!A2,Wednesday!$C$2:$C$4,"")+SUMIFS(Thursday!$B$2:$B$4,Thursday!$A$2:$A$4,Total!A2,Thursday!$C$2:$C$4,"")+SUMIFS(Friday!$B$2:$B$4,Friday!$A$2:$A$4,Total!A2,Friday!$C$2:$C$4,"")
What this does is uses a series of SUMIFS() functions to check each day if the name matches and if they were absent. If they weren't absent, it adds their hours to the total. If they were absent, it does nothing. So we get the correct hour totals. We could just count the absents and then do some math with the number of days absent, but I don't know if you have people who might work different hours different days (e.g. 4 hours Monday, 6 hours Tuesday, etc.)
To count the hours, we will use a simple COUNTA() function.
=COUNTA(Monday!C2,Tuesday!C2,Wednesday!C2,Thursday!C2,Friday!C2)
This counts all cells in that workers Absent columns that are not blank. This allows you flexibility to use any mark for absent as long as blank means "not absent".
There are other ways this spreadsheet could be made more robust with Table formatting, but I will leave it up to you to do the research.

EXCEL: multiple condition count and data listing/summary

I need to do a multiple condition count and data listing/summary in EXCEL.
I have an EXCEL file with the following:
A B C D <-- Columns
tennis Jan 4 Smith John
tennis Jan 4 Fellows Todd
tennis Jan 4 Biebs Justin
football Jul 8 Smith John
football Jul 8 Rucker Pete
tennis Aug 7 Smith John
etc...
I have to figure out by Last name/First Name (col D/col C), which activity they participated in (and it could be multiple times (ie - tennis on Jan 4 and Aug 7)).
I've researched VLOOKUP and countif and I can make them work on other files but I can't get them to work with this one. I know I could sort by names and manually count but trying to figure out a way to use multiple conditions to get the answer (without having to manipulate the file too much because it is not my file in terms of who is entering the information).
Any help is appreciated (even if it requires partial manual effort!) Anything is better than manually sorting the file multiple different ways.
Thanks!
-Dan
I suggest:
two extra columns in your source data. One (say wk) with =WEEKNUM(B2), the other (say bod) with =E2&", "&F2 and both copied down to suit.
a single pivot table (the fields can be rearranged to get different 'views' and/or filtered/sorted/grouped to suit)
If you find multiple activities for the same bod for the same wk, then click on the counts that are greater than 1 and the details should help to determine whether adding a flag may be appropriate, to distinguish camps.

Resources