Solved

consolidate data by two criteria

Posted on 2014-10-15
6
105 Views
Last Modified: 2014-10-20
I need to create a consolidated table from a longer table.  The raw data is as attached.  I need to consolidate by code and date.  ie: numbers of hours per code per date.  A pivot table gives me the correct data but I need it in column format to feed into another workbook.
Thanks in advance.
Example1.xlsx
0
Comment
Question by:acdecal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 40382606
You can use SUMIFS. Place this formula in H4 and copy down:

=SUMIFS(C:C,A:A,F4,B:B,G4)

Flyster
0
 

Author Comment

by:acdecal
ID: 40382811
That would required me to have data in columns F & G to use as criteria.  I have over 5,000 rows of raw data that I need to consolidate by week and code.  I have wrote VBA code to do this but I'm afraid it will take a considerable amount of time to run.  I was hoping for an easier solution like using the consolidation function or subtotaling or getting the data from a pivot table.
0
 

Accepted Solution

by:
acdecal earned 0 total points
ID: 40382874
I used the code below:   I little clunky but it works.


Sub consolidate()
Dim D1 As String, D2 As String, C1 As String, C2 As String
Dim i As Long, MH As Long, j As Long



j = 1
For i = 2 To 600
 MH = Cells(i, 3).Value + MH
 C1 = Cells(i, 1).Value

 C2 = Cells(i + 1, 1).Value
If C2 = "" Then GoTo A:
If C1 = C2 Then

 D1 = Cells(i, 2).Value
 D2 = Cells(i + 1, 2).Value
If D1 = D2 Then


Else

Cells(j, 10).Value = C1
Cells(j, 11).Value = D1
Cells(j, 12).Value = MH
MH = 0
j = j + 1



End If
Else

Cells(j, 10).Value = C1
Cells(j, 11).Value = D1
Cells(j, 12).Value = MH
MH = 0
j = j + 1


End If
Next i
A:
Cells(j, 10).Value = C1
Cells(j, 11).Value = D1
Cells(j, 12).Value = MH

End Sub
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 22

Expert Comment

by:Flyster
ID: 40383521
Here’s one way to achieve the result you’re looking for. Concatenate column A & B with this formula:

=A2&" "&TEXT(B2,"mm/dd/yyyy")

Then go to the Data tab and select Subtotal. In the “At change in” dropdown select the new field.  In the “Add subtotal to” dropdown select Mhs. See attached.
Example1.xlsx
0
 

Author Comment

by:acdecal
ID: 40383528
That's a clever way of determining a unique item but would require me to un-concatenation to get it to the format I need. Thanks for your efforts!
0
 

Author Closing Comment

by:acdecal
ID: 40391555
As stated
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

636 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