Roll up string/sum from multiple roll when criteria match

achantak

New Member
Joined
Sep 15, 2013
Messages
2
Hi,
Anyone could help me to roll up the data when there's only one key of ID and distribute to many (One to many)
One ID no. has only one title, but has many CCC, R, C,T as below table

The data I extract from the server becomes like this

ID noTitleCCCRCT
SAQ1234AAAH220.510.70.4
SAQ1234AAAC130.490.30.4
SAQ1234AAAD130.30.30.2
SAQ4321BBBH220.10.20.8
SAQ4321BBBH240.90.80.2
SAQ5478CCCC240.10.10.1

<tbody>
</tbody>

What I need is... One ID has one Title, consolidate CCC R, C, T from multiple roll to one roll and delete the roll that has been consolidated.

ID, title and CCC are string, R,C,T are numeric with 2 decimal place.
Quantity of CCC would not over 10 in maximum.

ID noTitleCCCRCT
SAQ1234AAAH22, C13, D131.31.31.0
SAQ4321BBBH22, H241.01.01.0
SAQ5478CCCC240.10.10.1

<tbody>
</tbody>

Understand that Pivot table can do that, but VBA is appreciated.

Thank you so much.

achantak
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this:-
Make backup of data as this code will modify your sheet data.
Code:
[COLOR="Navy"]Sub[/COLOR] MG15Sep20
[COLOR="Navy"]Dim[/COLOR] Rng     [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] Dn      [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Dim[/COLOR] oCat    [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]Dim[/COLOR] nRng    [COLOR="Navy"]As[/COLOR] Range
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
    [COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
        .CompareMode = vbTextCompare


[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    oCat = Dn & Dn.Offset(, 1)
        [COLOR="Navy"]If[/COLOR] Not .Exists(oCat) [COLOR="Navy"]Then[/COLOR]
            .Add oCat, Dn
        [COLOR="Navy"]Else[/COLOR]
            [COLOR="Navy"]If[/COLOR] nRng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR]
                [COLOR="Navy"]Set[/COLOR] nRng = Dn
            [COLOR="Navy"]Else[/COLOR]
                [COLOR="Navy"]Set[/COLOR] nRng = Union(nRng, Dn)
            [COLOR="Navy"]End[/COLOR] If
            .Item(oCat).Offset(, 2).Value = .Item(oCat).Offset(, 2).Value & "," & Dn.Offset(, 2).Value
            .Item(oCat).Offset(, 3).Value = .Item(oCat).Offset(, 3).Value + Dn.Offset(, 3).Value
            .Item(oCat).Offset(, 4).Value = .Item(oCat).Offset(, 4).Value + Dn.Offset(, 4).Value
            .Item(oCat).Offset(, 5).Value = .Item(oCat).Offset(, 5).Value + Dn.Offset(, 5).Value
        [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]If[/COLOR] Not nRng [COLOR="Navy"]Is[/COLOR] Nothing [COLOR="Navy"]Then[/COLOR] nRng.EntireRow.Delete
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,354
Members
449,155
Latest member
ravioli44

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