VBA Pivot Chart Colors

OWing

New Member
Joined
Nov 29, 2017
Messages
4
Hello,

I am using VBA to change the source data of a pivot cache which has several pivot tables connected to it. When the program runs, it connects the "main" pivot table to the new source data and then matches the remaining pivot tables to the "main" pivot table's index. Each pivot table has one pivot chart connected to it as well. When I attempt to change the source data, the chart legends will not change colors. In fact, most of the time, each entry in the legend is assigned the same color. For example, each stack of a stacked column chart and every line of a line chart has the same color. If I copy the file and the data into a new workbook with the same code and layout, the VBA program runs fine for about the first three times that I open the file and change the pivot cache of the pivot tables. However, after that, this problem occurs. When I check chart design and then look at the selected chart color, the correct color schema is selected but does not display in the chart. If I manually select the color schema I want after the error occurs, the chart colors only correctly display for the first member in the legend. Does anyone know why or at least have a solution? Any help would be greatly appreciated.
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

OWing

New Member
Joined
Nov 29, 2017
Messages
4
I figured it out. If I add .ClearToMatchColorStyle to my code after changing the colors, the problem stops.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,964
Messages
5,599,071
Members
414,281
Latest member
Engjamal2021

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
Top