Skip i'r prif gynnwys

Sut i glirio hidlwyr o'r holl daflenni gwaith mewn llyfr gwaith gweithredol yn Excel?

Gan dybio eich bod wedi creu hidlwyr lluosog ar draws gwahanol daflenni gwaith mewn llyfr gwaith Excel, a nawr rydych chi am glirio'r holl hidlwyr hyn ar unwaith. Fel rheol, mae angen i chi symud i'r daflen waith fesul un i wirio'r hidlydd ac yna ei glirio â llaw. A oes unrhyw ddull cyfleus i glirio hidlwyr o'r holl daflenni gwaith mewn llyfr gwaith gweithredol? Rhowch gynnig ar y dull yn yr erthygl hon.

Hidlwyr clir o'r holl daflenni gwaith mewn llyfr gwaith gweithredol gyda chod VBA


Hidlwyr clir o'r holl daflenni gwaith mewn llyfr gwaith gweithredol gyda chod VBA

Os gwelwch yn dda rhedeg y sgript VBA isod i glirio hidlwyr o'r holl daflenni gwaith yn y llyfr gwaith gweithredol.

1. Yn y llyfr gwaith mae angen i chi glirio hidlwyr ohono, pwyswch y Alt + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwlau. Yna copïwch a gludwch y sgript VBA isod i mewn i ffenestr y Modiwl. Gweler isod screenshot:

Cod VBA: Hidlwyr clir o'r holl daflenni gwaith yn y llyfr gwaith gweithredol

Sub Clear_fiter()()
'Updated by Extendoffice 20210625
    Dim xAF As AutoFilter
    Dim xFs As Filters
    Dim xLos As ListObjects
    Dim xLo As ListObject
    Dim xRg As Range
    Dim xWs As Worksheet
    Dim xIntC, xF1, xF2, xCount As Integer
    Application.ScreenUpdating = False
    On Error Resume Next
    For Each xWs In Application.Worksheets
        xWs.ShowAllData
        Set xLos = xWs.ListObjects
        xCount = xLos.Count
        For xF1 = 1 To xCount
         Set xLo = xLos.Item(xF1)
         Set xRg = xLo.Range
         xIntC = xRg.Columns.Count
         For xF2 = 1 To xIntC
            xLo.Range.AutoFilter Field:=xF2
         Next
        Next
    Next
    Application.ScreenUpdating = True

End Sub

3. Gwasgwch y F5 allwedd i redeg y cod. Yna caiff yr holl hidlwyr ar draws yr holl daflenni gwaith yn y llyfr gwaith cyfredol eu clirio ar unwaith.


Erthyglau perthnasol:

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
@Lorif - delete For Each xWs In Application.Worksheets and one of the Nexts
This comment was minimized by the moderator on the site
Which line should I change to restrict the macro to ONLY the active sheet, rather than all of them?Much appreciated!
This comment was minimized by the moderator on the site
hi, everytime I open the file the macro runs and the filters are cleared, how to avoid that "auto run" of the macro?
This comment was minimized by the moderator on the site
Hi Juan Moreno,
I am sorry for my mistake.Replace the first line:
Sub Auto_Open()withSub Clear_filter()with solve the problem.
This comment was minimized by the moderator on the site
this removes all filters, I wanted something that would clear the filters not remove them.
This comment was minimized by the moderator on the site
Hi Saima,I got your point. The code has been updated in the post to only clear the filters instead of removing them. Please to have a try and sorry for the inconvenience.<div data-tag="code">Sub Auto_Open()
'Updated by Extendoffice 20201113
Dim xAF As AutoFilter
Dim xFs As Filters
Dim xLos As ListObjects
Dim xLo As ListObject
Dim xRg As Range
Dim xWs As Worksheet
Dim xIntC, xF1, xF2, xCount As Integer
Application.ScreenUpdating = False
On Error Resume Next
For Each xWs In Application.Worksheets
xWs.ShowAllData
Set xLos = xWs.ListObjects
xCount = xLos.Count
For xF1 = 1 To xCount
Set xLo = xLos.Item(xF1)
Set xRg = xLo.Range
xIntC = xRg.Columns.Count
For xF2 = 1 To xIntC
xLo.Range.AutoFilter Field:=xF2
Next
Next
Next
Application.ScreenUpdating = True

End Sub
This comment was minimized by the moderator on the site
Thanks this help me alot ;=)
This comment was minimized by the moderator on the site
You fucking scumbag this deleted all our filters! Our whole python script was destroyed as a result of it costing us hours! GO TO HELL YOU SCUMBAGS!!!!!!!!!!!!!!!!
This comment was minimized by the moderator on the site
You're getting free help and degrading others for your own stupid mistakes. People like you deserve a special place in hell
This comment was minimized by the moderator on the site
Why didn't you test it fully before working on your latest file and don't you have backup... work on your IT habits before using harsh language.
This comment was minimized by the moderator on the site
Hi,
Sorry for the mistake. The code has been updated in the post to only clear the filters instead of removing them. Please to have a try and sorry for the inconvenience.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations