Přejít k hlavnímu obsahu

Jak vytisknout všechna pravidla podmíněného formátování v listu?

Je snadné zobrazit všechna pravidla podmíněného formátování v listu kliknutím Domů > Podmíněné formátování > Spravovat pravidla v aplikaci Excel, ale víte, jak vytisknout všechna pravidla formátování podmínek v tomto listu? Tento článek představí VBA k vyřešení tohoto problému.

Vytiskněte všechna pravidla podmíněného formátování v listu


šipka modrá pravá bublinaVytiskněte všechna pravidla podmíněného formátování v listu

Postupujte podle níže uvedených kroků a vytiskněte všechna pravidla podmíněného formátování v listu VBA.

1. Otevřete určený list, jehož pravidla podmíněného formátování vytisknete, a stiskněte Další + F11 společně otevřete okno Microsoft Visual Basic pro aplikace.

2, klikněte Vložit > Modula poté vložte pod kód VBA do nového okna modulu.

VBA: Seznam všech pravidel podmíněného formátování v aktivním listu

Sub M_snb()
Dim xRg As Range, xCell As Range
Dim xFormat As Object
Dim xFmStr, xFmAddress As String
Dim xDic As New Dictionary
Dim xSpArr, xOperatorArr
On Error Resume Next
Set xRg = ActiveSheet.Cells.SpecialCells(xlCellTypeAllFormatConditions)
If xRg Is Nothing Then Exit Sub
xDic.Item("Title") = "Type|Typename|Range|StopIfTrue|Operator|Formula1|Formula2|Formula3"
If xSpArr.Count = 0 Then
xSpArr = Split("Cell Value|Expression|Color Scale|DataBar|Top 10|Icon Sets||Unique Values|Text|Blanks|Time Period|Above Average||No Blanks||Errors|No Errors|||||", "|")
xOperatorArr = Split("xlBetween|xlNotBetween|xlEqual|xlNotEqual|xlGreater|xlLess|xlGreaterEqual|xlLessEqual", "|")
End If
For Each xCell In xRg
Set xFormat = xCell.FormatConditions(1)
xFmAddress = xFormat.AppliesTo.Address
If Not xDic.Exists(xFmAddress) Then
xDic.Item(xFmAddress) = xFormat.Type & "|" & xSpArr(xFormat.Type - 1) & "|" & xFmAddress & "|" & xFormat.StopIfTrue
If Not IsEmpty(xFormat.Operator) Then
xDic.Item(xFmAddress) = xDic.Item(xFmAddress) & "|" & xOperatorArr(xFormat.Operator - 1)
End If
If Not IsEmpty(xFormat.Formula1) Then
xDic.Item(xFmAddress) = xDic.Item(xFmAddress) & "|'" & xFormat.Formula1
End If
End If
Next
If ActiveWorkbook.Worksheets("FmCondictionList") Is Nothing Then
Sheets.Add.Name = "FmCondictionList"
End If
Sheets("FmCondictionList").Cells(1).Resize(xDic.Count) = Application.Transpose(xDic.items)
Sheets("FmCondictionList").Columns(1).TextToColumns , , , , 0, 0, 0, 0, -1, "|"
End Sub

3, klikněte Tools > Reference.

4. V dialogovém okně Reference - VBAProject zkontrolujte Microsoft Scripting Runtime a klepněte na tlačítko OK knoflík. Viz screenshot:

5. Nyní se vraťte do okna modulu, stiskněte F5 klíč nebo klikněte na Běh tlačítko pro spuštění tohoto VBA.

Nyní nový list s názvem „FmCondtionalList”Je vytvořen a přidán před aktivní list. V tomto listu získáte seznam všech pravidel podmíněného formátování.

6, klikněte Soubor > Tisk > Tisk vytisknout seznam pravidel podmíněného formátování.


šipka modrá pravá bublinaSouvisející články:

Nejlepší nástroje pro produktivitu v kanceláři

🤖 Kutools AI asistent: Revoluční analýza dat založená na: Inteligentní provedení   |  Generovat kód  |  Vytvořte vlastní vzorce  |  Analyzujte data a generujte grafy  |  Vyvolejte funkce Kutools...
Populární funkce: Najít, zvýraznit nebo identifikovat duplikáty   |  Odstranit prázdné řádky   |  Kombinujte sloupce nebo buňky bez ztráty dat   |   Kolo bez vzorce ...
Super vyhledávání: Více kritérií VLookup    VLookup s více hodnotami  |   VLookup na více listech   |   Fuzzy vyhledávání ....
Pokročilý rozevírací seznam: Rychle vytvořte rozevírací seznam   |  Závislý rozbalovací seznam   |  Vícenásobný výběr rozevíracího seznamu ....
Správce sloupců: Přidejte konkrétní počet sloupců  |  Přesunout sloupce  |  Přepnout stav viditelnosti skrytých sloupců  |  Porovnejte rozsahy a sloupce ...
Doporučené funkce: Zaměření mřížky   |  Návrhové zobrazení   |   Velký Formula Bar    Správce sešitů a listů   |  Knihovna zdrojů (Automatický text)   |  Výběr data   |  Zkombinujte pracovní listy   |  Šifrovat/dešifrovat buňky    Odesílat e-maily podle seznamu   |  Super filtr   |   Speciální filtr (filtr tučné/kurzíva/přeškrtnuté...) ...
Top 15 sad nástrojů12 Text Tools (doplnit text, Odebrat znaky, ...)   |   50+ Graf Typ nemovitosti (Ganttův diagram, ...)   |   40+ Praktické Vzorce (Vypočítejte věk na základě narozenin, ...)   |   19 Vložení Tools (Vložte QR kód, Vložit obrázek z cesty, ...)   |   12 Konverze Tools (Čísla na slova, Přepočet měny, ...)   |   7 Sloučit a rozdělit Tools (Pokročilé kombinování řádků, Rozdělit buňky, ...)   |   ... a více

Rozšiřte své dovednosti Excel pomocí Kutools pro Excel a zažijte efektivitu jako nikdy předtím. Kutools for Excel nabízí více než 300 pokročilých funkcí pro zvýšení produktivity a úsporu času.  Kliknutím sem získáte funkci, kterou nejvíce potřebujete...

Popis


Office Tab přináší do Office rozhraní s kartami a usnadňuje vám práci

  • Povolte úpravy a čtení na kartách ve Wordu, Excelu, PowerPointu, Publisher, Access, Visio a Project.
  • Otevřete a vytvořte více dokumentů na nových kartách ve stejném okně, nikoli v nových oknech.
  • Zvyšuje vaši produktivitu o 50%a snižuje stovky kliknutí myší každý den!
Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Regarding the comment by @Eagle, I modified the code to cycle up to 'xCell.FormatConditions.Count' and I retrieved more format conditions, but not all of them.
It appears that this change adds the formats on different ranges for the same cell, but not the same ranges with different formats for the same cell.
I'm not that familiar yet with the code that would extract these extra formats.
This comment was minimized by the moderator on the site
Works fine!
Just two notes regarding the comments before:
* Microsoft Scripting Library must be added, otherwise 'Dim xDic As New Dictionary' cannot be interpreted
* If you have more then 1 rules defined on the same Range, then only the first will be listed (code shell be extended with a cycle from 1 to xCell.FormatConditions.Count)

Thanks a lot!
This comment was minimized by the moderator on the site
Unfortunately doesn't work (excel 2013).
This comment was minimized by the moderator on the site
L'algo est mauvais, il n'y a pas de boucle pour couvrir les cas ou un range aurait plusieurs format conditionnels.
This comment was minimized by the moderator on the site
This works great, but is there a way to get a loop that includes all tabs?
This comment was minimized by the moderator on the site
For me it did create a tab and populate information however it was excluding a lot of the conditional formatting was not included. At the time I ran it I had 112 conditional formatting rules set up but only 8 records displayed in the tab.
This comment was minimized by the moderator on the site
Same for me - it only displayed 7 out of 14 conditional formatting rules. Is there any solution for that?
This comment was minimized by the moderator on the site
this does not work. It creates the tab but does not populate the conditional formatting information
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations