暂停"条件格式",但保留最后的更改



我在excel中的一张表上有一个GANTT图表,该图表使用有条件的格式,在每月约120个周期(列(内,有条件地为约50行填充7种不同的颜色。

您可以想象,这会创建一个非常缓慢的工作表。我曾考虑减少时段数量,但目前每个时段有2天,超过这一时间可能会导致日历看起来不准确。

我想看看我是否能";暂停";有条件的格式化,这样条件就不会在后台持续运行,但我想保留暂停前应用的格式化。

";如果为True则停止";该功能通过创建一个条件来停止所有格式化,使我走到了一半;冻结";但它并没有保留格式。

有什么想法吗?理想情况下不使用宏,因为这个文件最终会在共享驱动器上,我不想处理每个用户的权限问题。

谢谢!

保持条件格式颜色不是很容易。它需要在你的床单上添加一个按钮来保持颜色。该按钮将执行代码(见下文(,将当前条件格式颜色复制到单元格内部颜色。一个名为";HOLD_b";也应该放在纸上。这个单元格的值";TRUE";或";FALSE";必须用于第一个条件格式;如果为True则停止";已检查。到目前为止,您所拥有的一切都很好,只需添加该单元格和带有以下代码的按钮。

' HOLD CONDITIONAL FORMATING COLOR
' Button Click that will alternate between two states
' 1- hold the current conditional formatting color
' 2- Resume conditional formatting
' A conditional formatting rule must be set on the "HOLD_b" cell    
' value to set the formatting to "clear"
' It must be set at the top with the option "stop if true" checked

Private Sub Set_Color_Click()
Dim MyRangeArea As Range
Dim MyRange As Range

'=====  Set your Area Here ==============
Set MyRangeArea = Range("I6:M10")
'========================================

If Range("HOLD_b") Then  'HOLD_b is a cell to control formatting
For Each MyRange In MyRangeArea
MyRange.Interior.ColorIndex = -4142
Next MyRange
Range("HOLD_b") = False
Else
For Each MyRange In MyRangeArea
MyRange.Interior.Color = MyRange.Item(1).DisplayFormat.Interior.Color
Next MyRange
Range("HOLD_b") = True
End If
End Sub

最新更新