Skip to main content

Conas gach riail formáidithe coinníollach a phriontáil i mbileog oibre?

Is furasta na rialacha formáidithe coinníollach go léir a fheiceáil i mbileog oibre trí chliceáil Baile > Formáidiú Coinníollach > Rialacha a Bhainistiú in Excel, ach an bhfuil a fhios agat conas na rialacha formáidithe riocht uile sa bhileog oibre seo a phriontáil? Tabharfaidh an t-alt seo VBA isteach chun an fhadhb seo a réiteach.

Priontáil na rialacha formáidithe coinníollach go léir i mbileog oibre


mboilgeog cheart gorm saigheadPriontáil na rialacha formáidithe coinníollach go léir i mbileog oibre

Lean na céimeanna thíos chun na rialacha formáidithe coinníollach go léir a phriontáil i mbileog oibre le VBA.

1. Oscail an bhileog oibre shonraithe a phriontálfaidh tú agus a brúfaidh tú rialacha formáidithe coinníollach Eile + F11 eochracha le chéile chun an fhuinneog Microsoft Visual Basic for Applications a oscailt.

2. Cliceáil Ionsáigh > Modúil, agus ansin greamaigh faoi bhun chód VBA isteach i bhfuinneog an mhodúil nua.

VBA: Liostaigh na rialacha formáidithe coinníollach go léir sa bhileog oibre ghníomhach

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. Cliceáil uirlisí > tagairtí.

4. Sa bhosca dialóige Tagairtí - VBAProject, seiceáil an Microsoft Scripting Runtime rogha, agus cliceáil ar an OK cnaipe. Féach an pictiúr:

5. Anois agus tú ag filleadh ar fhuinneog an mhodúil, brúigh le do thoil F5 eochair nó cliceáil ar an Rith cnaipe chun an VBA seo a rith.

Bileog oibre nua anois darb ainm “Liosta FmCondtionalListCruthaítear agus cuirtear leis roimh an mbileog oibre ghníomhach. Agus gheobhaidh tú gach liostáil rialacha formáidithe coinníollach sa bhileog oibre seo.

6. Cliceáil Comhad > Print > Print chun liosta na rialacha formáidithe coinníollach a phriontáil.


mboilgeog cheart gorm saigheadEarraí gaolmhara:

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
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