Skip to main content

Conas scagairí a ghlanadh ó gach bileog oibre sa leabhar oibre gníomhach in Excel?

Má cheaptar gur chruthaigh tú iliomad scagairí thar bhileoga oibre éagsúla i leabhar oibre Excel, agus anois ba mhaith leat na scagairí seo go léir a ghlanadh ag an am céanna. De ghnáth, ní mór duit aistriú go dtí an bhileog oibre ceann ar cheann chun an scagaire a sheiceáil agus ansin é a ghlanadh de láimh. An bhfuil aon mhodh áisiúil ann chun scagairí a ghlanadh ó gach bileog oibre i leabhar oibre gníomhach? Bain triail as an modh san alt seo le do thoil.

Scagairí soiléire ó gach bileog oibre sa leabhar oibre gníomhach le cód VBA


Scagairí soiléire ó gach bileog oibre sa leabhar oibre gníomhach le cód VBA

Rith an script VBA thíos le do thoil chun scagairí a ghlanadh ó gach bileog oibre sa leabhar oibre gníomhach.

1. Sa leabhar oibre a gcaithfidh tú scagairí a ghlanadh uaidh, brúigh an Eile + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil Ionsáigh > Modúil. Ansin cóipeáil agus greamaigh an script VBA thíos i bhfuinneog an Mhodúil. Féach thíos an pictiúr:

Cód VBA: Scagairí soiléire ó gach bileog oibre sa leabhar oibre gníomhach

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. Brúigh an F5 eochair chun an cód a rith. Ansin glantar gach scagaire ar fud na mbileog oibre uile sa leabhar oibre reatha láithreach.


Earraí 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 (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