我试图在工作簿中列出所有条件格式设置规则,并在其他地方找到以下代码。该子例程列出了工作表的名称,应用的公式和应用的范围。我有两个问题:
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
请让我知道我是否可以阅读任何文档以更好地理解这一点。谢谢!