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.
 

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.
 

Forum statistics

Threads
1,085,495
Messages
5,384,004
Members
401,871
Latest member
allemandi

Some videos you may like

This Week's Hot Topics

Top