title: Set the chart colors to automatic in Excel VBA
body: <p>I have a macro that sets all the series on a stacked bar chart to have the same color,  as well as a couple other bits like this:</p>
  
  <pre><code>Sub RefreshLabels()
  
      ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
  
      Dim ch As Chart
      ActiveSheet.ChartObjects("ProjectChart").Activate
      Set ch = ActiveChart
      ch.SetElement (msoElementDataLabelCenter)
  
      Dim sc As SeriesCollection
      Set sc = ch.SeriesCollection
  
      Dim showLabel As Boolean
      If (Range("showLabels").Value = "Y") Then
          showLabel = True
      Else
          showLabel = False
      End If
  
      Dim sameColor As Boolean
      If (Range("sameColor").Value = "Y") Then
          sameColor = True
      Else
          sameColor = False
  
      End If
  
      Dim s As Series
      For Each s In sc
  
          If (sameColor = True) Then
              s.Border.Color = RGB(Range("rgb_r"), Range("rgb_g"), Range("rgb_b"))
              s.Interior.Color = RGB(Range("rgb_r"), Range("rgb_g"), Range("rgb_b"))
          Else
              'CODE HERE TO MAKE COLORS AUTOMATICALLY SELECTED FROM PALLETTE
          End If
  
          Set dl = s.DataLabels
          dl.ShowSeriesName = showLabel
          dl.ShowValue = False
  
  
      Next
  
  
  End Sub
  </code></pre>
  
  <p>However I need the option to change the series back to how the default stacked bar chart was, with the colors selected automatically to a palette of sorts.</p>
  
  <p>Let me know if you need any further information.</p>