0

Can I somehow find out if a cell is conditionally formatted? I don't mean if there is a CF rule in a particular cell, but if it is true.

My idea was to do something like this (in the immediate window) ?ActiveSheet.Range("D58").Interior.ColorIndex, but this returns -4142 even though the cell is filled with blue.


For context: My CF is checking if a cell value matches the value of a calculation, like this: "=A1+A50<>A24" and applies the CF if this is true. It's good to know if the two values don't match, it means somewhere there is a mistake. However, it'd be even better if I could, for example, insert a comment in cell A24 to show the user what result the calculation yields. Otherwise they have to check it for themselves.

braX
  • 11,506
  • 5
  • 20
  • 33
Alex
  • 515
  • 5
  • 19
  • 2
    `.DisplayFormat.Interior.Color`. – BigBen Feb 10 '20 at 17:22
  • In order to check if a range (`rng`) is conditionally formatted you can use: `rng.FormatConditions.count`. If it returns `0`, it is not conditionally formatted. If you need the real interior color (with or without conditional formatting) you can use `rng.DisplayFormat.Interior.Color` as @BigBen already stated. – FaneDuru Feb 10 '20 at 17:38
  • You can also just run the rules the conditional format uses to determine if it's true independent of whether the cell is formatted or not. – Mark S. Feb 10 '20 at 20:22

0 Answers0