macro for 4000 rows (merge & count duplicates items )

KalilMe

Active Member
Joined
Mar 5, 2021
Messages
343
Office Version
  1. 2016
Platform
  1. Windows
hi experts

I need macro run for about 4000 rows . so this is the simple data to understand me . it should merge duplicate item based on COL D and with merge duplicate items in COL B,C should contain comma and count the duplicate item based on COL D with summing QTY so the result should show from COL J: O with the same formatting and borders

CONC.xlsm
ABCDEFGHIJKLMNO
1DATEINVOICEORDERCODEBRANDTYPEORIGINQTYITEMINVOICEORDERCODECOUNTQTY
21/1/2021FRT-100/G-1OR-FR/1000FR-00BANANSOTR121FRT-100/G-1,2OR-FR/1000,1FR-00670
31/2/2021FRT-100/G-1OR-FR/1000FR-00BANANMATR132FRT-100/G-7,9OR-FR/1002,4FR-001210
41/3/2021FRT-100/G-2OR-FR/1001FR-00BANANSSTUT103FRT-100/G-8,10OR-FR/1003,5FR-002240
51/4/2021FRT-100/G-2OR-FR/1001FR-00BANANSOTR12
61/5/2021FRT-100/G-2OR-FR/1001FR-00BANANMATR13
71/6/2021FRT-100/G-2OR-FR/1001FR-00BANANSSTUT10
81/7/2021FRT-100/G-7OR-FR/1002FR-01ORANGMMNNT5
91/8/2021FRT-100/G-8OR-FR/1003FR-02ORANGASDKI20
101/9/2021FRT-100/G-9OR-FR/1004FR-01ORANGMMNNT5
111/10/2021FRT-100/G-10OR-FR/1005FR-02ORANGASDKI20
12
13
sss
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
With Power Pivot, create these two measures shown in the attachments

Book2
ABCDE
3CODEInvoicesOrdersCount of INVOICESum of QTY
4FR-00FRT-100/G-1, FRT-100/G-1, FRT-100/G-2, FRT-100/G-2, FRT-100/G-2, FRT-100/G-2OR-FR/1000, OR-FR/1000, OR-FR/1001, OR-FR/1001, OR-FR/1001, OR-FR/1001670
5FR-01FRT-100/G-7, FRT-100/G-9OR-FR/1002, OR-FR/1004210
6FR-02FRT-100/G-8, FRT-100/G-10OR-FR/1003, OR-FR/1005240
Sheet2


to see a tutorial on how I achieved this is at: Excel: Reporting Text in a Pivot Table - Strategic Finance
 

Attachments

  • Capture.JPG
    Capture.JPG
    30.5 KB · Views: 4
  • Capture1.JPG
    Capture1.JPG
    26.6 KB · Views: 4
Upvote 0
Formula based

Book1
ABCDEFGHIJKLMNO
1DATEINVOICEORDERCODEBRANDTYPEORIGINQTYITEMINVOICEORDERCODECOUNTQTY
201-01-21FRT-100/G-1OR-FR/1000FR-00BANANSOTR121FRT-100/G-1, FRT-100/G-2OR-FR/1000, OR-FR/1001FR-00670
301-02-21FRT-100/G-1OR-FR/1000FR-00BANANMATR132FRT-100/G-7, FRT-100/G-9OR-FR/1002, OR-FR/1004FR-01210
401-03-21FRT-100/G-2OR-FR/1001FR-00BANANSSTUT103FRT-100/G-8, FRT-100/G-10OR-FR/1003, OR-FR/1005FR-02240
501-04-21FRT-100/G-2OR-FR/1001FR-00BANANSOTR12
601-05-21FRT-100/G-2OR-FR/1001FR-00BANANMATR13
701-06-21FRT-100/G-2OR-FR/1001FR-00BANANSSTUT10
801-07-21FRT-100/G-7OR-FR/1002FR-01ORANGMMNNT5
901-08-21FRT-100/G-8OR-FR/1003FR-02ORANGASDKI20
1001-09-21FRT-100/G-9OR-FR/1004FR-01ORANGMMNNT5
1101-10-21FRT-100/G-10OR-FR/1005FR-02ORANGASDKI20
Sheet1
Cell Formulas
RangeFormula
K2:K4K2=TEXTJOIN(", ",,UNIQUE(FILTER($B$2:$B$4001,$D$2:$D$4001=M2)))
L2:L4L2=TEXTJOIN(", ",,UNIQUE(FILTER($C$2:$C$4001,$D$2:$D$4001=M2)))
M2:M4M2=SORT(UNIQUE(FILTER($D$2:$D$4001,($D$2:$D$4001<>""))))
N2:N4N2=COUNTIF($D$2:$D$4001,M2)
O2:O4O2=SUMIF($D$2:$D$4001,M2,$H$2:$H$4001)
J3:J4J3=J2+1
Dynamic array formulas.
 
Upvote 0
@Sanjeev1976 maybe you didn't check the OP's profile, but it shows 2016, so cannot use the formulae in cols K, L & M
 
Upvote 0
Hi Fluff,
Yes, missed checking the profile, will check the same in future before responding
 
Upvote 0
thanks guys , if that's possible by vba will be great ;)
 
Upvote 0

Forum statistics

Threads
1,216,045
Messages
6,128,484
Members
449,455
Latest member
jesski

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