0
A
回答
0
对于第一种格式,我能够拼凑出以下几点:
Private Sub CheckBox1_Click()
Dim rngMyRange As Range
Set rngMyRange = ActiveWorkbook.Worksheets("tim-vgr_hgn").Range("C3:AO46") 'Set your range here
If rngMyRange.FormatConditions.Count = 0 Then 'Set Conditional Formats
With rngMyRange
.FormatConditions.AddColorScale ColorScaleType:=3
' Format the first color as green
.FormatConditions(1).ColorScaleCriteria(1).Type = xlConditionValueNumber
.FormatConditions(1).ColorScaleCriteria(1).Value = 0
.FormatConditions(1).ColorScaleCriteria(1).FormatColor.Color = RGB(0, 255, 0)
' Format the second color as yellow
.FormatConditions(1).ColorScaleCriteria(2).Type = xlConditionValueNumber
.FormatConditions(1).ColorScaleCriteria(2).Value = 120
.FormatConditions(1).ColorScaleCriteria(2).FormatColor.Color = RGB(255, 255, 0)
' Format the third color as red
.FormatConditions(1).ColorScaleCriteria(3).Type = xlConditionValueNumber
.FormatConditions(1).ColorScaleCriteria(3).Value = 7200
.FormatConditions(1).ColorScaleCriteria(3).FormatColor.Color = RGB(255, 0, 0)
End With
Else 'Clear Conditional Formats
rngMyRange.FormatConditions.Delete
End If
End Sub
但是,我怎么重新创建第二格式?
我将开始第二种格式的新问题。
相关问题
- 1. 用于打印的条件格式化与开关的公式
- 2. 使用VBA条件格式化
- 3. 无条件的Excel和VBA格式化
- 4. Application.OnTime VBA没有关闭和打开excel
- 5. 条件格式或使用VBA格式
- 6. 如何使用VBA格式化已关闭的Excel工作表
- 7. 条件格式化公式/ VBA
- 8. NGINX有条件地打开/关闭proxy_intercept_errors
- 9. 打开/关闭菜单条件
- 10. 2表格关闭和打开
- 11. jquery切换打开和关闭2格
- 12. 使用VBA复制有条件格式化的单元格
- 13. 打开关闭表格
- 14. 使用perl打开和关闭网页
- 15. 使用cmd打开和关闭程序
- 16. 使用OpenCV打开和关闭
- 17. 使用bash打开和关闭进程
- 18. Excel中使用VBA为正则表达式条件格式化
- 19. vba条件格式化与Worksheet_SelectionChange
- 20. 条件格式化vba与if
- 21. vba条件格式化到列
- 22. Excel VBA条件格式化不执行
- 23. VBA格式化条件格式化循环中的数字
- 24. 使用C关闭打开的文件
- 25. 关闭由vba宏用c打开的模式#
- 26. VBA打开excel,修改(Rank),关闭excel
- 27. 显式打开和关闭游标
- 28. 关闭和打开文件之间的条件
- 29. 格式打开时关闭复选框事件,格式重新加载时关闭格式
- 30. 打开和关闭盒(格)使用CSS或jQuery的
您可以使用'.FormatConditions.Delete'去除条件,如果你想再次启用它,你可以使用'.FormatConditions.Add'方法给定范围。 [参考](http://www.ozgrid.com/forum/showthread.php?t=138066) – newguy
切换一个条件格式开/关,使用'= AND(一些公式,toggleboolean)',因此你可以控制通过调整'toggleboolean'来打开/关闭 – Rosetta
我给出的第一个例子不使用公式。 – posfan12