I need to know: how to get colors made by color scale of conditional formatting of Excel 2010 throught VBA code. Those colors will be subsequently assigned by VBA as chart background according to the following image:
www.lnkm.cz/Slozka/Example.jpg http://www.lnkm.cz/Slozka/Example.jpg
I did a research on various web sides and:
<Cell>.FormatConditions(index that is active).Interior.ColorIndex
but in my case it don’t work because of error “Object doesn’t support this property or method”So I’m asking:
I believe that it has to work somehow.
if no better answer is provided, you can try this workaround:
=Sheet1!A1
)""
, i.e. empty string literal (2 double quotes))UPDATE:
or you can try to compute the color by linear approximation for each R, G, B channel if the conditional format uses only 2 base colors (r1, g1, b1) and (r2, g2, b2) for 2 corner cases which can be
min
and max
value, e.g.: 0 - 4 000min
and max
percent, e.g.: 10% - 90% min
and max
percentile, e.g.: 0th percentile - 100th percentilefor percent / percentile options you first need to convert an actual value to the percent / percentile value, then if value < min
or value > max
use the corner colors, otherwise:
r = r1 + (r2 - r1) * (value - min_value) / (max_value - min_value)
g = ...
b = ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With