excel - VBA 条件格式打印格式
问题描述
我正在尝试列出工作簿中的所有条件格式规则,并在其他地方找到以下代码。该子例程列出了工作表的名称、应用的公式和应用的范围。我有两个问题:
- 如何添加一个额外的列来显示格式的外观?
- 有没有办法让我更改 Excel 选项卡中的规则并将它们刷新到条件格式规则管理器?如何保持其中的顺序?
Sub List_Conditional_Formatting_Rules() ' Print all conditional formatting rules in the all worksheets Application.ScreenUpdating = False Dim ws As Worksheet, wsCF As Worksheet, NR As Long Dim CFrule As FormatCondition, Rng As range On Error Resume Next Sheets.Add(After:=Sheets(Sheets.Count)).Name = "CF Rules" 'add sheet Set wsCF = Sheets("CF Rules") wsCF.range("A1:C1").Value = [{"Sheet","Formula","Range"}] NR = 2 'define starting row For Each ws In Worksheets If ws.Name <> "CF Rules" Then Set Rng = ws.Cells For Each CFrule In Rng.FormatConditions wsCF.range("A" & NR).Value = ws.Name ' rule names wsCF.range("B" & NR).Value = "'" & CFrule.Formula1 ' formula names wsCF.range("C" & NR).Value = CFrule.AppliesTo.Address ' applied area ' want to add a column to show how the format actually looks like NR = NR + 1 Next CFrule End If Next ws wsCF.Columns.AutoFit Application.ScreenUpdating = False MsgBox ("All conditional formatting rules are printed.") End Sub
请让我知道是否有任何文件可以阅读以更好地理解这一点。谢谢!
解决方案
推荐阅读
- c# - OpenTK - Useability of Accumulation Buffer
- amazon-web-services - AWS lambda 事件参数:Records 何时在其中保存多个项目?
- blueprintjs - BlueprintJS 不渲染组件
- python - 为什么 Flask 'POST' 不返回简单的 JSON 对象?
- html - 为什么我的 css 不会影响我的 html 的字体颜色?
- javascript - 如何在 React 组件中进行两次条件检查
- c# - Angular 应用程序无法在 dotnet core / IIS 下启动
- swift - iOS Flutter 插件依赖问题
- python - 代码优化帮助(循环到张量操作)
- c++ - 如何将二维世界坐标转换为二维屏幕坐标?