VBA to summarize data

adammon

New Member
Joined
Apr 8, 2015
Messages
14
Hello,

Can someone help me out with creating a VBA code to summarize the following data set?

DE
1SKUOrdered
200001-BLACK-S1
300001-DKBRN-XL1
400308-BKWHT-O/S2
500308-BKWHT-O/S2
600308-ROYAL-O/S1
700611-PINE-O/S2
802427-MODEL-L3
902427-MODEL-L3
1002427-MODEL-M3
1102427-MODEL-M2
1202427-MODEL-S2
1302427-MODEL-S1
1402427-MODEL-XL2
1502427-MODEL-XL1

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
USPACK - Order summary

Here's what I'm trying to accomplish:

KL
2SKUOrdered
300001-BLACK-S1
400001-DKBRN-XL1
500308-BKWHT-O/S4
600308-ROYAL-O/S1
700611-PINE-O/S2
802427-MODEL-L6
902427-MODEL-M5
1002427-MODEL-S3

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
USPACK - Order summary
Normally I would create a pivot table or the consolidation tool, but I need the data to be more user friendly so I can use it with other formulas.

Thanks.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You can do that with formulae


Excel 2013/2016
KL
200001-BLACK-S1
300001-DKBRN-XL1
400308-BKWHT-O/S4
500308-ROYAL-O/S1
600611-PINE-O/S2
702427-MODEL-L6
802427-MODEL-M5
902427-MODEL-S3
1002427-MODEL-XL3
Index
Cell Formulas
RangeFormula
L2=SUMIF(D$2:D$16,K2,E$2:E$15)
K2{=INDEX(D$2:D$15,MATCH(0,COUNTIF(K$1:K1,D$2:D$15),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Or with VBA
Code:
Sub Summary()
   Dim Cl As Range
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("D2", Range("D" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = .Item(Cl.Value) + Cl.Offset(, 1).Value
      Next Cl
      Range("K2").Resize(.Count).Value = Application.Transpose(.Keys)
      Range("J2").Resize(.Count).Value = Application.Transpose(.Items)
   End With
End Sub
 
Upvote 0
Thank you for this. The VBA code works great.

The formula would also work, but the user wouldn't have column K as a reference for the index match. I'm essentially trying to build a tool so the user wouldn't need to make any edits to the data. Rather just paste some information on the sheet and run the macro.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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