Solved

Timesheet Analysis -- Quickly add up times for individuals

Posted on 2014-09-19
3
97 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 33

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

749 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