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.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I figured it out. If I add .ClearToMatchColorStyle to my code after changing the colors, the problem stops.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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