How to get the background color from a Conditional Formatting in Excel using VBA

前端 未结 4 736
北海茫月
北海茫月 2020-11-28 15:00

I would like to obtain the cell background color assigned using a conditional formatting rule in Excel in my VBA script. I realized that using Range.Interior.Color

4条回答
  •  心在旅途
    2020-11-28 15:48

    If you want to know the color of a cell that has been colored by a conditional formatting rule (CFR) then use Range.DisplayFormat.Interior.Color¹.

    If you want to definitively know what color a cell may or may not have been colored by a CFR you need to iterate through the CFRs that could be affecting that cell and look at each of the Range.FormatConditions(*x*).Interior.Color.

    Documentation: range.DisplayFormat

    ¹ Note: .DisplayFormat is not available for a worksheet UDF.

提交回复
热议问题