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:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
have you considered a pivot table?

Hi Steve,

I've played around with pivot tables, but I can't figure out how where to pout everything and how to get all the week ending calculations into a monthly summary!

I'm pretty much a clueless excel newbie with this much data to sort :(
 
Last edited:
Upvote 0
Project NumberProject NameProject TypeProject StatusStaff NameWeek Ending DateHrsBase Cost RateTS Codehelper1
1AlphaAbsenceOn GoingAdam01/11/2015820Core Time160
1AlphaAbsenceOn GoingBarry01/11/2015825Core Time200
1AlphaAbsenceOn GoingCharlie01/11/2015830Core Time240
2BetaHolidayOn GoingAdam01/09/20151020Core Time200
2BetaHolidayOn GoingAdam08/09/20152020Core Time400
2BetaHolidayOn GoingCharlie01/10/2015530Core Time150
2BetaHolidayOn GoingCharlie08/10/20150.530Core Time15
3GammaFeeCompletedAdam25/10/20154020Core Time800
3GammaFeeCompletedAdam01/11/20153020Core Time600
3GammaFeeCompletedAdam08/11/20152020Core Time400
3GammaFeeCompletedAdam15/11/20152520Core Time500
3GammaFeeCompletedAdam22/11/20154020Core Time800
3GammaFeeCompletedAdam29/11/201517.520Core Time350
3GammaFeeCompletedAdam06/12/20152320Core Time460
3GammaFeeCompletedAdam13/12/20154020Core Time800
3GammaFeeCompletedAdam20/12/20153520Core Time700
4DeltaFeeOn GoingDavid25/10/20154030Core Time1200
4DeltaFeeOn GoingDavid01/11/20151040OT 1400
4DeltaFeeOn GoingDavid08/11/20151040OT 1400
4DeltaFeeOn GoingDavid29/11/2015555OT 2275
4DeltaFeeOn GoingDavid06/12/2015555OT 2275
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
01/09/201501/10/201501/11/201501/12/2015
30/09/201531/10/201530/11/201531/12/2015
Project NumberProject NameProject TypeProject StatusSeptemberOctoberNovemberDecemberTotal Project Cost
1AlphaAbsenceOn Going006000600
2BetaHolidayOn Going60016500765
3GammaFeeCompleted0800265019605410
4DeltaFeeOn Going0120010752752550
tot monthly costs6002165432522359325
much easier with the helper column
you need to think about using week ending dates in the main table and calendar months in the summary table
eg week ending 1/11/15 has 6 days in october
alpha november 600 formula is
=SUMPRODUCT(($B$2:$B$22=$B38)*($J$2:$J$22)*($F$2:$F$22>G$34-1)*($F$2:$F$22<G$35+1))

<colgroup><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Try this:-
Results sheet2
Code:
[COLOR=Navy]Sub[/COLOR] MG03Nov35
[COLOR=Navy]Dim[/COLOR] Rng [COLOR=Navy]As[/COLOR] Range, Dn [COLOR=Navy]As[/COLOR] Range, n [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] Mth [COLOR=Navy]As[/COLOR] [COLOR=Navy]Integer,[/COLOR] Ac [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] Q [COLOR=Navy]As[/COLOR] Variant
[COLOR=Navy]Dim[/COLOR] Col [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] K [COLOR=Navy]As[/COLOR] Variant
[COLOR=Navy]Set[/COLOR] Rng = Range(Range("B2"), Range("B" & Rows.Count).End(xlUp))
[COLOR=Navy]With[/COLOR] CreateObject("System.Collections.ArrayList")
        [COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] Dn [COLOR=Navy]In[/COLOR] Rng.Offset(, 4)
            [COLOR=Navy]If[/COLOR] Not .Contains(MonthName(Month(Dn.Value))) [COLOR=Navy]Then[/COLOR] .Add MonthName(Month(Dn.Value))
        [COLOR=Navy]Next[/COLOR]
            .Sort: .Reverse
            ReDim ray(1 To Rng.Count, 1 To 5 + .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"
        [COLOR=Navy]For[/COLOR] n = 5 To 4 + .Count
            ray(1, n) = .toarray()(n - .Count - 1)
        [COLOR=Navy]Next[/COLOR] n
[COLOR=Navy]End[/COLOR] With

n = 1
[COLOR=Navy]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
    [COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] Dn [COLOR=Navy]In[/COLOR] Rng
        [COLOR=Navy]For[/COLOR] Ac = 5 To UBound(ray, 2) - 1
            [COLOR=Navy]If[/COLOR] Month("1-" & ray(1, Ac) & "-2000") = Month(Dn.Offset(, 4).Value) [COLOR=Navy]Then[/COLOR] Col = Ac
        [COLOR=Navy]Next[/COLOR] Ac
        [COLOR=Navy]If[/COLOR] Not .Exists(Dn.Value) [COLOR=Navy]Then[/COLOR]
            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
            .Add Dn.Value, Array(n, ray(n, Col))
        [COLOR=Navy]Else[/COLOR]
            Q = .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)
            .Item(Dn.Value) = Q
        [COLOR=Navy]End[/COLOR] If
    [COLOR=Navy]Next[/COLOR]


n = n + 1
ray(n, 1) = "Total Monthly Costs"
[COLOR=Navy]For[/COLOR] Ac = 5 To UBound(ray, 2)
    [COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] K [COLOR=Navy]In[/COLOR] .keys
        ray(n, Ac) = ray(n, Ac) + ray(.Item(K)(0), Ac)
    [COLOR=Navy]Next[/COLOR] K
[COLOR=Navy]Next[/COLOR] Ac
[COLOR=Navy]End[/COLOR] With


[COLOR=Navy]With[/COLOR] Sheets("Sheet2").Range("A1").Resize(n, UBound(ray, 2))
    .NumberFormat = "#,##0"
    .Value = ray
    .Columns.AutoFit
    .Borders.Weight = 2
[COLOR=Navy]End[/COLOR] [COLOR=Navy]With[/COLOR]
[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick
 
Upvote 0
NB:- The previous code would not Resize for New Months.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG03Nov44
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Q [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Dim[/COLOR] Dic [COLOR="Navy"]As[/COLOR] Object, K [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("B2"), Range("B" & Rows.Count).End(xlUp))
[COLOR="Navy"]Set[/COLOR] Dic = CreateObject("scripting.dictionary")
Dic.CompareMode = vbTextCompare


[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng.Offset(, 4)
    [COLOR="Navy"]If[/COLOR] Not Dic.exists(Month(Dn.Value)) [COLOR="Navy"]Then[/COLOR]
        Dic.Add Month(Dn.Value), MonthName(Month(Dn.Value))
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]With[/COLOR] Application
    ReDim mray(1 To Dic.Count)
        [COLOR="Navy"]For[/COLOR] n = .Min(Dic.keys) To .Max(Dic.keys)
            [COLOR="Navy"]If[/COLOR] Dic.exists(n) [COLOR="Navy"]Then[/COLOR]
                c = c + 1
                mray(c) = Dic(n)
            [COLOR="Navy"]End[/COLOR] If
        [COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] With
ReDim ray(1 To Rng.Count, 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"
        
        [COLOR="Navy"]For[/COLOR] n = 5 To 5 + Dic.Count - 1
            ray(1, n) = mray(n - 4)
        [COLOR="Navy"]Next[/COLOR] n
 Dic.RemoveAll
 n = 1
 [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
        [COLOR="Navy"]For[/COLOR] Ac = 5 To UBound(ray, 2) - 1
            [COLOR="Navy"]If[/COLOR] Month("1-" & ray(1, Ac) & "-2000") = Month(Dn.Offset(, 4).Value) [COLOR="Navy"]Then[/COLOR] Col = Ac
        [COLOR="Navy"]Next[/COLOR] Ac
        [COLOR="Navy"]If[/COLOR] Not Dic.exists(Dn.Value) [COLOR="Navy"]Then[/COLOR]
            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))
        [COLOR="Navy"]Else[/COLOR]
            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
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR]


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




[COLOR="Navy"]With[/COLOR] Sheets("Sheet2").Range("A1").Resize(n, UBound(ray, 2))
    .NumberFormat = "#,##0"
    .Value = ray
    .Columns.AutoFit
    .Borders.Weight = 2
[COLOR="Navy"]End[/COLOR] With


[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi Mick,

Thank you for the VBA code.

I've tried to run it but it comes up with the following Run-time error '9': Subscript out of range
ray(n, 1) = "Total Monthly Costs"

How do I rectify this?

Thanks in advance :)
 
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,155
Members
449,208
Latest member
emmac

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