Summarizing data from long list to Master spreadsheet

mileijit

New Member
Joined
Oct 31, 2015
Messages
10
Hi,

I have a really long list of data that I'd like to summarize into a Master file.

The long list of data I have is like this:
Project NumberProject NameProject TypeProject StatusStaff NameWeek Ending DateHrsBase Cost RateTS Code
1AlphaAbsenceOn GoingAdam01/11/2015820Core Time
1AlphaAbsenceOn GoingBarry01/11/2015825Core Time
1AlphaAbsenceOn GoingCharlie01/11/2015830Core Time
2BetaHolidayOn GoingAdam01/09/20151020Core Time
2BetaHolidayOn GoingAdam08/09/20152020Core Time
2BetaHolidayOn GoingCharlie01/10/2015530Core Time
2BetaHolidayOn GoingCharlie08/10/20150.530Core Time
3GammaFeeCompletedAdam25/10/20154020Core Time
3GammaFeeCompletedAdam01/11/20153020Core Time
3GammaFeeCompletedAdam08/11/20152020Core Time
3GammaFeeCompletedAdam15/11/20152520Core Time
3GammaFeeCompletedAdam22/11/20154020Core Time
3GammaFeeCompletedAdam29/11/201517.520Core Time
3GammaFeeCompletedAdam06/12/20152320Core Time
3GammaFeeCompletedAdam13/12/20154020Core Time
3GammaFeeCompletedAdam20/12/20153520Core Time
4DeltaFeeOn GoingDavid25/10/20154030Core Time
4DeltaFeeOn GoingDavid01/11/20151040OT 1
4DeltaFeeOn GoingDavid08/11/20151040OT 1
4DeltaFeeOn GoingDavid29/11/2015555OT 2
4DeltaFeeOn GoingDavid06/12/2015555OT 2

<tbody>
</tbody>

What I'd like is to have a Master sheet automatically capture the following data:
Project NumberProject NameProject TypeProject StatusSeptemberOctoberNovemberDecemberTotal Project
Cost
1AlphaAbsenceOn Going--600-600
2BetaHolidayOn Going600165--765
3GammaFeeCompleted-8002,6501,9605,410
4DeltaFeeOn Going-1,2001,075-2,550
Total Monthly Costs6002,1654,3252,2359,325

<tbody>
</tbody>



So basically, all the months are added together, and multiplied by the cost rate in the same row to create an overall project cost table.
After which I can sort and filter as required.

Any assistance would be greatly appreciated as I have no idea where to start with this!!!
 
Last edited:
Hi Mick,

Thank you so much for the code. I've been playing around with it and have managed to get it working with this...

Code:
Sub Master()
Dim Rng As Range, Dn As Range, n As Long, c As Long, Ac As Long, Col As Long, Q As Variant
Dim Dic As Object, K As Variant
Set Rng = Range(Range("B2"), Range("B" & Rows.Count).End(xlUp))
Set Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbTextCompare


For Each Dn In Rng.Offset(, 4)
    If Not Dic.exists(Month(Dn.Value)) Then
        Dic.Add Month(Dn.Value), MonthName(Month(Dn.Value))
    End If
Next
With Application
    ReDim mray(1 To Dic.Count)
        For n = .Min(Dic.keys) To .Max(Dic.keys)
            If Dic.exists(n) Then
                c = c + 1
                mray(c) = Dic(n)
            End If
        Next n
End With
ReDim ray(1 To Rng.Count + 1, 1 To 5 + Dic.Count)
            ray(1, 1) = "Project Number": ray(1, 2) = "Project Name"
            ray(1, 3) = "Project type": ray(1, 4) = "Project status": ray(1, UBound(ray, 2)) = "Total Project Cost"
        
        For n = 5 To 5 + Dic.Count - 1
            ray(1, n) = mray(n - 4)
        Next n
 Dic.RemoveAll
 n = 1
 For Each Dn In Rng
        For Ac = 5 To UBound(ray, 2) - 1
            If Month("1-" & ray(1, Ac) & "-2000") = Month(Dn.Offset(, 4).Value) Then Col = Ac
        Next Ac
        If Not Dic.exists(Dn.Value) Then
            n = n + 1
            ray(n, Col) = Dn.Offset(, 5).Value * Dn.Offset(, 6).Value
            ray(n, 1) = Dn.Offset(, -1).Value: ray(n, 2) = Dn.Value
            ray(n, 3) = Dn.Offset(, 1).Value: ray(n, 4) = Dn.Offset(, 2).Value
            Dic.Add Dn.Value, Array(n, ray(n, Col))
        Else
            Q = Dic.Item(Dn.Value)
            Q(1) = Q(1) + Dn.Offset(, 5).Value * Dn.Offset(, 6).Value
            ray(Q(0), Col) = ray(Q(0), Col) + Dn.Offset(, 5).Value * Dn.Offset(, 6).Value
            ray(Q(0), UBound(ray, 2)) = Q(1)
            Dic.Item(Dn.Value) = Q
        End If
    Next


n = n + 1
ray(n, 1) = "Total Monthly Costs"
For Ac = 5 To UBound(ray, 2)
    For Each K In Dic.keys
        ray(n, Ac) = ray(n, Ac) + ray(Dic(K)(0), Ac)
    Next K
Next Ac


With Sheets("Master").Range("A1").Resize(n, UBound(ray, 2))
    .NumberFormat = "#,##0"
    .Value = ray
    .Columns.AutoFit
    .Borders.Weight = 2
End With


End Sub

... However, it seems to miss out calculating the 'Total Project Cost' for some rows, and I can't figure out why!



I also have a separate sheet ("Invoices") that has more data I'd like to pull into the "Master" sheet.

The headings are: Invoice Number / Project Branch / Project Number* / Project Name* / Project Director / Transaction Date / Fees Net Amount / Consultancy Net Amount
*These have the same details as in the list pulled to compile the Master sheet.

I'd like to include the info from Project Branch and Project Director into columns in the Master Sheet (all projects will have the same value), just like the Project Name data.

Additionally, I'd like to calculate the sum of the Fees Net Amount and Consultancy Net Amount in the same fashion as the Total Project Cost column and insert them in the "Master" too.
Note: The Fees Net Amount and Consultancy Net Amount don't need to be broken up into monthly summaries (based on the Transaction Date column), but all the rows for X project need to be added together to give the Total amounts for each project.

I hope the above makes sense, and you can help with this as well!!! :)
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,216,503
Messages
6,131,020
Members
449,615
Latest member
Nic0la

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top