Skip to main content

Conas méid gach bileog oibre de leabhar oibre a sheiceáil?

Má cheaptar go bhfuil leabhar mór oibre agat ina bhfuil iliomad bileoga oibre, agus anois, ba mhaith leat méid gach bileog oibre a fháil amach chun a fháil amach cén bhileog is gá a laghdú. An bhfuil aon mhodhanna gasta ann chun déileáil leis an tasc seo?

Seiceáil méid gach bileog oibre le cód VBA

Seiceáil méid gach bileog oibre le Kutools le haghaidh Excel


mboilgeog cheart gorm saighead Seiceáil méid gach bileog oibre le cód VBA

Leis an gcód VBA seo a leanas, is féidir leat méid gach bileog oibre a fháil go tapa i do leabhar oibre. Déan mar seo le do thoil:

1. Coinnigh síos an ALT + F11 eochracha, agus osclaíonn sé an Fuinneog Microsoft Visual Basic for Applications.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Fuinneog an Mhodúil.

Cód VBA: Seiceáil méid gach bileog oibre i leabhar oibre </ p>

Sub WorksheetSizes()
'Update 20140526
Dim xWs As Worksheet
Dim Rng As Range
Dim xOutWs As Worksheet
Dim xOutFile As String
Dim xOutName As String
xOutName = "KutoolsforExcel"
xOutFile = ThisWorkbook.Path & "\TempWb.xls"
On Error Resume Next
Application.DisplayAlerts = False
Err = 0
Set xOutWs = Application.Worksheets(xOutName)
If Err = 0 Then
    xOutWs.Delete
    Err = 0
End If
With Application.ActiveWorkbook.Worksheets.Add(Before:=Application.Worksheets(1))
    .Name = xOutName
    .Range("A1").Resize(1, 2).Value = Array("Worksheet Name", "Size")
End With
Set xOutWs = Application.Worksheets(xOutName)
Application.ScreenUpdating = False
xIndex = 1
For Each xWs In Application.ActiveWorkbook.Worksheets
    If xWs.Name <> xOutName Then
        xWs.Copy
        Application.ActiveWorkbook.SaveAs xOutFile
        Application.ActiveWorkbook.Close SaveChanges:=False
        Set Rng = xOutWs.Range("A1").Offset(xIndex, 0)
        Rng.Resize(1, 2).Value = Array(xWs.Name, VBA.FileLen(xOutFile))
        Kill xOutFile
        xIndex = xIndex + 1
    End If
Next
Application.ScreenUpdating = True
Application.Application.DisplayAlerts = True
End Sub

3. Ansin brúigh F5 eochair chun an cód seo a fhorghníomhú, agus bileog oibre nua darb ainm Kutools le haghaidh Excel cuirfear isteach sa leabhar oibre reatha é ina bhfuil ainm gach bileog oibre agus méid comhaid, agus is é an t-aonad Giotán. Féach an pictiúr:

doc-seic-bhileog-mhéid1


mboilgeog cheart gorm saighead Seiceáil méid gach bileog oibre le Kutools le haghaidh Excel

Má tá tú Kutools le haghaidh Excel, Lena Leabhar Oibre Scoilt fóntais, is féidir leat an leabhar oibre iomlán a roinnt i gcomhaid ar leithligh, agus ansin dul chuig an bhfillteán sonrach chun méid gach comhaid a sheiceáil.

Kutools le haghaidh Excel Cuimsíonn sé níos mó ná 300 uirlis áisiúil Excel. Saor chun triail a dhéanamh gan aon teorannú i 30 lá. Faigh é anois.

Tar éis Kutools a shuiteáil le haghaidh Excel, déan na céimeanna seo a leanas:

1. Oscail an leabhar oibre is mian leat chun méid gach bileog oibre a sheiceáil, agus cliceáil Fiontar > Uirlisí Leabhar Oibre > Leabhar Oibre Scoilt, féach ar an scáileán:

doc-seic-bhileog-mhéid1

2. Sa an Leabhar Oibre Scoilt dialóg, seiceáil na bileoga oibre go léir agus cliceáil Scoilt cnaipe, agus ansin fillteán a shonrú chun na comhaid nua leabhar oibre a chur. Féach screenshots:

doc-seic-bhileog-mhéid3
-1
doc-seic-bhileog-mhéid4

3. Agus ansin sábhálfar gach bileog oibre de do leabhar oibre reatha mar chomhad Excel scartha, is féidir leat dul chuig d’fhillteán ar leith chun méid gach leabhair oibre a sheiceáil.

doc-seic-bhileog-mhéid1

Chun níos mó eolais a fháil faoin ngné Leabhar Oibre Scoilt seo.


Earraí gaolmhara:

Conas leabhar oibre a roinnt chun comhaid Excel a scaradh in Excel?

Conas bileoga agus bileoga oibre a easpórtáil agus a shábháil mar leabhar oibre nua in Excel?

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 (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Should probably add this between lines 9 and 10 in case some sheets are hidden to avoid the code crashing
For Each xWs In Sheets: xWs.Visible = True: Next
This comment was minimized by the moderator on the site
Thank you, very helpful,
I had a bunch of unnecessary formulas in a sheet and i just deleted that the file now works fine.
All these happen only because i could find the size of each sheet,
Thanks again.

Anson
This comment was minimized by the moderator on the site
Very VeryVeryVeryVery helpful.
Thank you!!
This comment was minimized by the moderator on the site
' Part 3 of 3 '--- paste break --- ' Format the output sheet Application.Sheets(xOutName).Activate Columns("B:B").Select Selection.NumberFormat = "#,##0_);(#,##0)" Columns("A:B").Select Columns("A:B").EntireColumn.AutoFit Range("A1").Select ' Even better, format it as a table. ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1:B" & xIndex), , xlYes).Name = "WorksheetSizes" Application.ScreenUpdating = True Application.Application.DisplayAlerts = True Application.StatusBar = "" Application.Cursor = xlDefault Exit Sub ErrorHandler: MsgBox "Error #" & Err.Number & " - " & Err.Description & vbCrLf & "in procedure WorksheetSizes" End Sub
This comment was minimized by the moderator on the site
' Part 2 of 3 '--- paste break --- xWs.Visible = xlSheetVisible ' xOutFile = ThisWorkbook.Path & "\" & xWs.Name & ".xls" xWs.CopyQ Application.ActiveWorkbook.SaveAs xOutFile Application.ActiveWorkbook.Close SaveChanges:=False Set rng = xOutWs.Range("A1").Offset(xIndex, 0) rng.Resize(1, 2).Value = Array(xWs.Name, VBA.FileLen(xOutFile)) Kill xOutFile xIndex = xIndex + 1 End If Next ' Repeat the above for chart sheets. For Each xWs In Application.ActiveWorkbook.Charts If xWs.Name xOutName Then Application.StatusBar = "Calculating Worksheet Sizes, Sheet " & xIndex & " of " & ActiveWorkbook.Worksheets.count - 1 & " - " & xWs.Name Debug.Print "Calculating Worksheet Sizes, Sheet " & xIndex & " of " & ActiveWorkbook.Worksheets.count - 1 & " - " & xWs.Name DoEvents ' include this so CTRL+Break can be detected. xWs.Visible = xlSheetVisible xOutFile = ThisWorkbook.Path & "\" & xWs.Name & ".xls" xWs.Copy Application.ActiveWorkbook.SaveAs xOutFile Application.ActiveWorkbook.Close SaveChanges:=False Set rng = xOutWs.Range("A1").Offset(xIndex, 0) rng.Resize(1, 2).Value = Array(xWs.Name, VBA.FileLen(xOutFile)) 'Kill xOutFile xIndex = xIndex + 1 End If Next '--- paste break ---
This comment was minimized by the moderator on the site
Here is a copy of the routine with a few enhancements I added. I had to break it into multiple posts due to the site limits. Public Sub WorksheetSizes() 'Update 20140526 ' https://www.extendoffice.com/documents/excel/1682-excel-check-size-of-each-sheet.html<br />' ' BS 4/4/2016: Modified to have a status bar and format the output. ' Fixed for hidden sheets that caused it to crash. ' Added support for Chart sheets Dim xWs As Object ' Worksheet or Chart Dim rng As Range Dim xOutWs As Worksheet Dim xOutFile As String Dim xOutName As String Dim xIndex As Long On Error GoTo ErrorHandler Application.Cursor = xlWait xOutName = "KutoolsforExcel" xOutFile = ThisWorkbook.Path & "\TempWb.xls" On Error Resume Next Application.DisplayAlerts = False Err = 0 Set xOutWs = Application.Worksheets(xOutName) If Err = 0 Then xOutWs.Delete Err = 0 End If With Application.ActiveWorkbook.Worksheets.Add(Before:=Application.Worksheets(1)) .Name = xOutName .Range("A1").Resize(1, 2).Value = Array("Worksheet Name", "Size") End With Set xOutWs = Application.Worksheets(xOutName) Application.ScreenUpdating = False xIndex = 1 Debug.Print ThisWorkbook.Path For Each xWs In Application.ActiveWorkbook.Worksheets If xWs.Name xOutName Then Application.StatusBar = "Calculating Worksheet Sizes, Sheet " & xIndex & " of " & ActiveWorkbook.Worksheets.count - 1 & " - " & xWs.Name Debug.Print "Calculating Worksheet Sizes, Sheet " & xIndex & " of " & ActiveWorkbook.Worksheets.count - 1 & " - " & xWs.Name DoEvents ' include this so CTRL+Break can be detected. '--- paste break ---
This comment was minimized by the moderator on the site
Hey Ben, Could you repaste the whole string of text with items #2 and #4 from your email added in? MY VBA knowledge is pretty limited and I'm not sure exactly where to add them into the For loop. My workbook has a number of hidden sheets and keeps crashing during the macro execution. Thanks, Bob
This comment was minimized by the moderator on the site
Thanks for providing the code snippet to the public. It's one of the better routines I found. Here are a few tweaks to it: 1) Add "Dim xIndex as Long" to the top if you're using Option Explicit. 2) Add this inside the For loop to handle hidden sheets (otherwise it crashes): xWs.Visible = xlSheetVisible 3) If you have full page "chart" sheets, you need to copy the code for the loop and iterate through the Application.ActiveWorkbook.Charts collection. If you do this, change the declaration of xWs from "Sheet" to "Object". 4) For a cheap status indicator (or for debugging issues) add this line inside the For loop: Debug.Print "Calculating Worksheet Sizes, Sheet " & xIndex & " of " & ActiveWorkbook.Worksheets.count - 1 & " - " & xWs.Name
This comment was minimized by the moderator on the site
Very helpful. Thank you!!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations