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,081,425
Messages
5,358,604
Members
400,505
Latest member
JacquiT

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top