Preskoči na glavno vsebino

Kako natisniti vsa pravila pogojnega oblikovanja na delovni list?

Vsa pravila pogojnega oblikovanja si lahko preprosto ogledate na delovnem listu s klikom HOME > Pogojno oblikovanje > Upravljanje pravil v Excelu, a ali veste, kako natisniti vsa pravila za oblikovanje pogojev na tem delovnem listu? Ta članek bo predstavil VBA za rešitev te težave.

Natisnite vsa pravila pogojnega oblikovanja na delovni list


puščica modri desni mehurčekNatisnite vsa pravila pogojnega oblikovanja na delovni list

Sledite spodnjim korakom, da natisnete vsa pravila pogojnega oblikovanja na delovni list podjetja VBA.

1. Odprite navedeni delovni list, katerega pravila pogojnega oblikovanja boste natisnili, in pritisnite druga + F11 da odprete okno Microsoft Visual Basic for Applications.

2. Kliknite Vstavi > Moduliin nato pod novo kodo VBA prilepite v novo okno modula.

VBA: Na aktivnem delovnem listu navedite vsa pravila pogojnega oblikovanja

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. Kliknite Orodja > Reference.

4. V pogovornem oknu Reference - VBAProject preverite Izvajanje Microsoftovih skriptov in kliknite na OK . Oglejte si posnetek zaslona:

5. Zdaj se vrnete v okno modula, pritisnite F5 ali kliknite Run za zagon tega VBA.

Zdaj je nov delovni list z imenom »FmCondtionalList"Je ustvarjen in dodan pred aktivnim delovnim listom. Na tem delovnem listu boste dobili seznam pravil za pogojno oblikovanje.

6. Kliknite file > Tiskanje > Tiskanje da natisnete seznam pravil pogojnega oblikovanja.


puščica modri desni mehurčekSorodni članki:

Najboljša pisarniška orodja za produktivnost

🤖 Kutools AI Aide: Revolucionirajte analizo podatkov na podlagi: Inteligentna izvedba   |  Ustvari kodo  |  Ustvarite formule po meri  |  Analizirajte podatke in ustvarite grafikone  |  Prikličite funkcije Kutools...
Priljubljene funkcije: Poiščite, označite ali identificirajte dvojnike   |  Izbriši prazne vrstice   |  Združite stolpce ali celice brez izgube podatkov   |   Krog brez formule ...
Super iskanje: Več kriterijev VLookup    Multiple Value VLookup  |   VLookup na več listih   |   Nejasno iskanje ....
Napredni spustni seznam: Hitro ustvarite spustni seznam   |  Odvisni spustni seznam   |  Večkrat izberite spustni seznam ....
Upravitelj stolpcev: Dodajte določeno število stolpcev  |  Premakni stolpce  |  Preklop stanja vidnosti skritih stolpcev  |  Primerjaj obsege in stolpce ...
Predstavljene funkcije: Mrežni fokus   |  Pogled oblikovanja   |   Velika vrstica formule    Upravitelj delovnih zvezkov in listov   |  Knjižnica virov (Samodejno besedilo)   |  Izbirnik datuma   |  Združite delovne liste   |  Šifriranje/dešifriranje celic    Pošljite e-pošto po seznamu   |  Super filter   |   Poseben filter (filter krepko/ležeče/prečrtano ...) ...
15 najboljših kompletov orodij12 Besedilo Orodja (dodajanje besedila, Odstrani znake,...)   |   50 + Graf Vrste (Gantt Chart,...)   |   40+ Praktično Formule (Izračunajte starost glede na rojstni dan,...)   |   19 vstavljanje Orodja (Vstavite kodo QR, Vstavi sliko s poti,...)   |   12 Pretvorba Orodja (Številke v besede, Pretvorba valut,...)   |   7 Spoji in razdeli Orodja (Napredne kombinirane vrstice, Razdeljene celice,...)   |   ... in več

Napolnite svoje Excelove spretnosti s Kutools za Excel in izkusite učinkovitost kot še nikoli prej. Kutools za Excel ponuja več kot 300 naprednih funkcij za povečanje produktivnosti in prihranek časa.  Kliknite tukaj, če želite pridobiti funkcijo, ki jo najbolj potrebujete...

Opis


Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50%in vsak dan zmanjša na stotine klikov miške za vas!
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