将条件格式单元格的颜色更改为真实颜色

Change colour of conditionally formatted cells to real colour

我有一个 Excel sheet,其中包含条件格式不同的单元格。我需要保留条件格式的初始颜色,尽管在接下来的计算中该值会发生变化。

我的解决方案 atm 是手动选择和填充单元格。是否有可能将其自动化?

这里是 excel sheet [1] 的部分截图:https://i.stack.imgur.com/g3ePL.png

你可以使用这样的东西:

Sub fixCF_Formatting()
    On Error Resume Next
    Dim CF_range As Range
    Set CF_range = ActiveSheet.Cells.SpecialCells(xlCellTypeAllFormatConditions)
    On Error GoTo 0
    If Not CF_range Is Nothing Then
    Application.ScreenUpdating = False
    Dim cell As Range
    For Each cell In CF_range
        If cell.Interior.Color <> cell.DisplayFormat.Interior.Color Then _
                        cell.Interior.Color = cell.DisplayFormat.Interior.Color
    Next cell
    ' remove the CF if desired
    CF_range.FormatConditions.Delete
    End If
End Sub

如果您想保留 CF 规则,请注释掉末尾的 Delete 行。