PDA

View Full Version : [SOLVED:] Color Chart Columns by Conditionally Formatted Cell Color



arns
11-21-2017, 05:06 AM
20992
Category color is Conditionally Formatted based on Text (i.e. cell color will change automatically with change of letter).

Goal: Automatically color each column in chart with same color as in category (based on Conditional Formatting).

20993

Is someone out there that could help me to reach my goal?

arns

mancubus
11-21-2017, 07:59 AM
check this out:
https://www.get-digital-help.com/2013/09/14/format-fill-color-on-a-column-chart-based-on-cell-color/

mancubus
11-22-2017, 01:21 AM
adopted from:

https://www.get-digital-help.com/2013/09/14/format-fill-color-on-a-column-chart-based-on-cell-color/




Sub vbax_61383_Color_Chart_Columns_Based_on_Conditional_formatting()

Dim vAddress As Range
Dim i As Long, ColorVal As Long
Dim R As Long, G As Long, B As Long

With Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1) 'change sheet and chart references to suit
Set vAddress = ActiveSheet.Range(Split(Split(.Formula, ",")(1), "!")(1)).Columns(2) 'X values from col A and B. so set range to the second col, ie col B
For i = 1 To vAddress.Cells.Count
ColorVal = vAddress.Cells(i).DisplayFormat.Interior.Color 'Displayformat to return conditional formatting color
R = ColorVal Mod 256 'return RED value from ColorVal
G = (ColorVal \ 256) Mod 256 'return GREEN value from ColorVal
B = (ColorVal \ 256 \ 256) Mod 256 'return BLUE value from ColorVal
.Points(i).Format.Fill.ForeColor.RGB = RGB(R, G, B)
Next i
End With

End Sub

arns
11-22-2017, 05:33 AM
Spot on excellent! Exactly what I was looking for.
Thank you mancubus.

mancubus
11-22-2017, 06:25 AM
you are welcome.

thanks for the feedback and marking the thread as solved.