Problem with choosing multiple item under selected field in pivot table (using VBA)

Yozie

New Member
Joined
Jun 30, 2018
Messages
1
I have problem to code macro to select multiple item under a particular field in pivot table.
The criteria for the item being used is coming from a table in another sheet (brand)

Brand
[TABLE="width: 10"]
[TR]
[TD][TABLE="width: 64"]
[TR]
[TD="class: xl65, width: 64"]Brand Cde[/TD]
[/TR]
[TR]
[TD="class: xl66"]AAA[/TD]
[/TR]
[TR]
[TD="class: xl66"]BBB[/TD]
[/TR]
[TR]
[TD="class: xl66"]CCC[/TD]
[/TR]
[TR]
[TD="class: xl66"]BIO[/TD]
[/TR]
[TR]
[TD="class: xl66"]BCL[/TD]
[/TR]
[/TABLE]
[/TD]
[/TR]
[/TABLE]

PivotTableSheet (pick some sample only):
[TABLE="width: 306"]
[TR]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]Values[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]CATEGORY[/TD]
[TD]BRAND[/TD]
[TD]Item Code[/TD]
[TD] Jun-17[/TD]
[TD] Jul-17[/TD]
[TD] Aug-17[/TD]
[TD] Sep-17[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120001000[/TD]
[TD] 38[/TD]
[TD] (11)[/TD]
[TD] (22)[/TD]
[TD] 15[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120002000[/TD]
[TD] 85[/TD]
[TD] 33[/TD]
[TD] (6)[/TD]
[TD] 9[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120003000[/TD]
[TD] 70[/TD]
[TD] 14[/TD]
[TD] (8)[/TD]
[TD] 12[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120004000[/TD]
[TD] 116[/TD]
[TD] 41[/TD]
[TD] 7[/TD]
[TD] 35[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120005000[/TD]
[TD] 87[/TD]
[TD] 9[/TD]
[TD] (12)[/TD]
[TD] 6[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120006000[/TD]
[TD] 89[/TD]
[TD] 41[/TD]
[TD] 14[/TD]
[TD] 22[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120007000[/TD]
[TD] 49[/TD]
[TD] 27[/TD]
[TD] (3)[/TD]
[TD] 23[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120008000[/TD]
[TD] 9[/TD]
[TD] 6[/TD]
[TD] 5[/TD]
[TD] 11[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120009000[/TD]
[TD] 103[/TD]
[TD] 41[/TD]
[TD] 3[/TD]
[TD] 30[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120010000[/TD]
[TD] 59[/TD]
[TD] 1[/TD]
[TD] (17)[/TD]
[TD] 6[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120011000[/TD]
[TD] 54[/TD]
[TD] 35[/TD]
[TD] (4)[/TD]
[TD] 15[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120012000[/TD]
[TD] 50[/TD]
[TD] (3)[/TD]
[TD] 3[/TD]
[TD] (2)[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120013000[/TD]
[TD] 77[/TD]
[TD] 28[/TD]
[TD] 2[/TD]
[TD] 10[/TD]
[/TR]
[TR]
[TD]PREMIUM[/TD]
[TD]BCL[/TD]
[TD]010120014000[/TD]
[TD] 45[/TD]
[TD] (7)[/TD]
[TD] (4)[/TD]
[TD] 1[/TD]
[/TR]
[/TABLE]

I have tried using looping mechanism (for i = 0 to ...) to pick all the brand.
But it does not work.
The brand name in the table can change dynamically (as per user needs).
Any idea how to solve this?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

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