Solved

Timesheet Analysis -- Quickly add up times for individuals

Posted on 2014-09-19
3
95 Views
Last Modified: 2014-09-19
I am using Excel 2013 ... vba

I have uploaded a sheet. It has two columns with headers "Name" and "Hours".

There are two named ranges...

The range "Name" has duplicate entries.   Each entry has an entry in the "hours" column.

I would like a lightning fast analysis.  I need the total hours for each "Name" entry.   Ideally, a 2 dimensional array would be great.

I would prefer it in VBA, but open to suggestions.


At first, this problem seemed easy.   It's not  so easy!!
Accumulated-Time.xlsx
0
Comment
Question by:peispud
3 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40332404
Why not do it as a PivotTable? Fairly easy (apart from needing headers), and the user can edit it if necessary.

Otherwise:

    Columns("A:A").Select
    Selection.Copy
    Columns("D:D").Select
    ActiveSheet.Paste
    ActiveSheet.Range("D:D").RemoveDuplicates Columns:=1, Header:=xlYes
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("D1"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("D:D")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    introw = 2
    Do
        Cells(introw, 5).Formula = "=SUMIF(A:A,D" & introw & ",B:B)"
        introw = introw + 1
    Loop Until Cells(introw, 4) = ""
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 40332548
Assuming the columns are sorted by name, you can use the Subtotal routine to add subtotals at each change. Again, this will need headers.

If you have a fixed list of names, you can copy the list to a separate list with single entry per person and then use the SUMIF function on a separate sheet.

Assuming data on sheet 1 columns A & B and formula on sheet2 (or elsewhere):

=SUMIF(Sheet1!A:A,A1,Sheet1B:B)  

where A1 contains the name to be summarised, copied down for the complete list.

This will be as quick as clicking to the next tab as this will update with each recalculation. Additional names will just need adding to bottom of list and formula copied down to accommodate.

Thanks
Rob H
0
 

Author Closing Comment

by:peispud
ID: 40333303
Thank you both for the answers.  My question was answered quickly and correctly so this question should be closed.

I will be re-asking the question again though.    I've recently discovered the  "scripting dictionary" object and hope to integrate it into the solution.

Thank you.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now