Solved

Timesheet Analysis -- Quickly add up times for individuals

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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.

708 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

14 Experts available now in Live!

Get 1:1 Help Now