Solved

Timesheet Analysis -- Quickly add up times for individuals

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

860 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