Solved

How to combine rows while suming a single column in Excel

Posted on 2014-09-17
8
221 Views
Last Modified: 2014-09-17
I'm trying to take the following attached table and combine all instances of a single ticket into a single row with the 'total_seconds' column sum'ed together.

Nearly the same thing was done in http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_26311764.html but I was not able to reverse engineer the VB Script. Perhaps someone can help get that script working for something like this document.

Script:
Dim i As Integer
i = Range("A1").End(xlDown).Row

Application.ScreenUpdating = False

    Range("D1").Select
    ActiveCell.FormulaR1C1 = "Quantity"
    Range("D2").Select
    ActiveCell.FormulaR1C1 = _
        "=SUMPRODUCT((RC[-3]=R2C1:R" & i & "C1)*(RC[-2]=R2C2:R" & i & "C2),R2C3:R" & i & "C3)"
    Range("D2").Select
    Selection.Copy
    Range(Selection, Selection.End(xlDown)).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Selection.Copy
    Range("D2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("C2").Select
    Application.CutCopyMode = False
    Selection.EntireColumn.Delete
    Range("A1").Select
    Range("A1:C" & i).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
        "D1"), Unique:=True
    Range("A1:C1").Select
    Selection.EntireColumn.Delete
    Range("A1").Select

Application.ScreenUpdating = True

End Sub

Open in new window

Report-2014-09-01-to-2014-09-16.xlsx
0
Comment
Question by:bc it
  • 4
  • 4
8 Comments
 

Author Comment

by:bc it
Comment Utility
Found another, clearer example here http://www.experts-exchange.com/Software/Microsoft_Applications/Q_23065563.html

But the Scripting.Dictionary class does not exist for my Mac 2011 version of Excel......
0
 
LVL 4

Expert Comment

by:rlarian
Comment Utility
why not just use a pivot table?
Row Labels      Sum of total_seconds
747993      69195
754371      58646
756493      22600
757159      607
758087      3756
758234      7287
758273      893
758328      71
758615      7
758618      6
758627      170
758649      46
758887      4671
758988      2
759217      506
759275      3935
0
 

Author Comment

by:bc it
Comment Utility
@rlarian, I've been trying and I've been able to get that far, but am not sure how I'd set up the pivot table to display all the other columns along with those totals. Know how'd that would be set up?
0
 
LVL 4

Expert Comment

by:rlarian
Comment Utility
Ticket Created and ticket updated would not make sense to include, but do you want the rest of the columns in the final result?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:bc it
Comment Utility
Exactly, so I would end up with a list of ticket numbers along with all of their metadata, including the sum'ed total_seconds
0
 
LVL 4

Accepted Solution

by:
rlarian earned 500 total points
Comment Utility
take a look at the attached. sometime the quick and dirty will get the job done - pivot table and vlookup. the pivot 2 sheet shows a multi tiered table that might give you some ideas.
0
 
LVL 4

Expert Comment

by:rlarian
Comment Utility
0
 

Author Comment

by:bc it
Comment Utility
Very cool, thanks! I'll use this to make it happen!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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

11 Experts available now in Live!

Get 1:1 Help Now