Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to check the size of each worksheet of workbook?

Supposing you have a large workbook which contains multiple worksheets, and now, you want to find out the size of each worksheet to determine which sheet need to be reduced. Are there any quick methods to deal with this task?

Check the size of each worksheet with VBA code

Check the size of each worksheet with Kutools for Excel

Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
  • Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
  • More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
  • Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
  • Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
  • Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
  • Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
  • More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.

arrow blue right bubble Check the size of each worksheet with VBA code


With the following VBA code, you can quickly get the size of each worksheet in your workbook. Please do as this:

1. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Check the size of each worksheet in a workbook< /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. Then press F5 key to execute this code, and a new worksheet named KutoolsforExcel will be inserted into the current workbook which contains each worksheet name and file size, and the unit is Bit. See screenshot:

doc-check-sheet-size1


arrow blue right bubble Check the size of each worksheet with Kutools for Excel

If you have Kutools for Excel, with its Split Workbook utility, you can split the whole workbook into separate files, and then go to the specific folder to check the size of each file.

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.

After installing Kutools for Excel, do with following steps:

1. Open the workbook you want to check the size of its each worksheet, and click Enterprise > Workbook Tools > Split Workbook, see screenshot:

doc-check-sheet-size1

2. In the Split Workbook dialog, check all the worksheets and click Split button, and then specify a folder to put the new workbook files. See screenshots:

doc-check-sheet-size3
-1
doc-check-sheet-size4

3. And then each worksheet of your current workbook will be saved as separated Excel file, you can go to your specific folder to check the size of each workbook.

doc-check-sheet-size1

To know more about this Split Workbook feature.


Related articles:

How to split a workbook to separate Excel files in Excel?

How to export and save sheets and worksheets as new workbook in Excel?


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Juliana · 7 months ago
    Very VeryVeryVeryVery helpful.
    Thank you!!
  • To post as a guest, your comment is unpublished.
    Ben S. · 3 years ago
    ' 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
  • To post as a guest, your comment is unpublished.
    Ben S. · 3 years ago
    ' 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 ---
  • To post as a guest, your comment is unpublished.
    Ben S. · 3 years ago
    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
    '
    ' 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 ---
  • To post as a guest, your comment is unpublished.
    Bob M · 3 years ago
    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
  • To post as a guest, your comment is unpublished.
    Ben S. · 3 years ago
    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
  • To post as a guest, your comment is unpublished.
    Anand · 5 years ago
    Very helpful.
    Thank you!!