The conditional formatting you’re showing in the screenshot indicates a “Graded Color Scale” type. Unfortunately, this type of conditional formatting rule doesn’t create a FormatCondition object that can be accessed like the standard conditional formatting rules in VBA. Instead, it’s a more complex rule that Excel applies dynamically based on the value of the cell relative to other cells in the range.
The colors for this type of conditional formatting are not set as direct properties that can be easily read. Instead, they are calculated on-the-fly by Excel depending on the cell’s value and the gradient scale defined.
If you still need to extract the color for a cell with this type of conditional formatting, you would have to manually calculate the color based on the cell’s value and the gradient thresholds defined in the conditional formatting rule. However, this is complex and would involve a detailed understanding of the algorithm Excel uses for gradient scales, which is not publicly documented.
If you’re looking to extract the specific RGB values for the start, midpoint, and end of the gradient, you can attempt to access the ColorScaleCriteria of the FormatConditions object, which can give you the colors that are set for the minimum, midpoint, and maximum of the scale. However, translating a cell’s value into a position on that scale and then into an RGB value is a manual process and can be quite challenging to implement correctly.
For cells that are not at the minimum, midpoint, or maximum, you would need to interpolate between these colors based on the cell’s value, which as mentioned, is not straightforward and would require custom code to approximate Excel’s behavior.
If you still want to proceed with this, you could extract the minimum, midpoint, and maximum colors and attempt to interpolate between them. If you need assistance with that, I can guide you on how to get started with the code to extract these threshold colors.