Excel工作簿的大小相当大

Excel工作簿的大小相当大,excel,size,Excel,Size,我有一个很大的工作簿(大约30 MB)。我意识到这与一些人相比是相当小的,但数学似乎不符合要求 总共有19张,我有大约15-20个命名范围 除四张外,所有这些图纸的使用范围都很小(小于100行25列) 四个表中的两个表(最小格式)约为35000行40列,由数据粘贴组成,数据粘贴值来自单独的文件,总计约20 MB 其他图纸不是表格,也没有格式化,大约9000行100列,11000行5列 所以我的问题是:额外的10MB来自哪里 编辑: 请注意,我已经将每张纸上的使用范围减少到最低限度。此外,工作

我有一个很大的工作簿(大约30 MB)。我意识到这与一些人相比是相当小的,但数学似乎不符合要求

  • 总共有19张,我有大约15-20个命名范围

  • 除四张外,所有这些图纸的使用范围都很小(小于100行25列)

  • 四个表中的两个表(最小格式)约为35000行40列,由数据粘贴组成,数据粘贴值来自单独的文件,总计约20 MB

  • 其他图纸不是表格,也没有格式化,大约9000行100列,11000行5列

所以我的问题是:额外的10MB来自哪里

编辑:


请注意,我已经将每张纸上的使用范围减少到最低限度。此外,工作簿是从公司模板复制的,带有重要的VBA,但该文件小于1MB。

当您将不同文件中的数据复制到一个文件中时,通常会出现此问题,因为Excel无法正确管理最后一行和最后一列的编号,因此使用大量数据存储空单元格的值

尝试以下方法

第一次尝试

使用以下Excel Diet VBA脚本重置最大列数和行号

Attribute VB_Name = "Module1"
Option Explicit

Sub ExcelDiet()

    Dim j               As Long
    Dim k               As Long
    Dim LastRow         As Long
    Dim LastCol         As Long
    Dim ColFormula      As Range
    Dim RowFormula      As Range
    Dim ColValue        As Range
    Dim RowValue        As Range
    Dim Shp             As Shape
    Dim ws              As Worksheet

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    On Error Resume Next

    For Each ws In Worksheets
        With ws
             'Find the last used cell with a formula and value
             'Search by Columns and Rows
            On Error Resume Next
            Set ColFormula = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
            Set ColValue = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, _
            LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
            Set RowFormula = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
            Set RowValue = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
            On Error GoTo 0

             'Determine the last column
            If ColFormula Is Nothing Then
                LastCol = 0
            Else
                LastCol = ColFormula.Column
            End If
            If Not ColValue Is Nothing Then
                LastCol = Application.WorksheetFunction.Max(LastCol, ColValue.Column)
            End If

             'Determine the last row
            If RowFormula Is Nothing Then
                LastRow = 0
            Else
                LastRow = RowFormula.Row
            End If
            If Not RowValue Is Nothing Then
                LastRow = Application.WorksheetFunction.Max(LastRow, RowValue.Row)
            End If

             'Determine if any shapes are beyond the last row and last column
            For Each Shp In .Shapes
                j = 0
                k = 0
                On Error Resume Next
                j = Shp.TopLeftCell.Row
                k = Shp.TopLeftCell.Column
                On Error GoTo 0
                If j > 0 And k > 0 Then
                    Do Until .Cells(j, k).Top > Shp.Top + Shp.Height
                        j = j + 1
                    Loop
                    If j > LastRow Then
                        LastRow = j
                    End If
                    Do Until .Cells(j, k).Left > Shp.Left + Shp.Width
                        k = k + 1
                    Loop
                    If k > LastCol Then
                        LastCol = k
                    End If
                End If
            Next

            .Range(.Cells(1, LastCol + 1), .Cells(.Rows.Count, .Columns.Count)).EntireColumn.Delete
            .Range("A" & LastRow + 1 & ":A" & .Rows.Count).EntireRow.Delete
        End With
    Next

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

End Sub
第二次尝试


将所有数据复制到一个全新的文件中并保存。

当您将不同文件中的数据复制到一个文件中时,通常会出现此问题,因为Excel无法正确管理最后的行数和最后的列数,因此使用大量数据存储空单元格的值

尝试以下方法

第一次尝试

使用以下Excel Diet VBA脚本重置最大列数和行号

Attribute VB_Name = "Module1"
Option Explicit

Sub ExcelDiet()

    Dim j               As Long
    Dim k               As Long
    Dim LastRow         As Long
    Dim LastCol         As Long
    Dim ColFormula      As Range
    Dim RowFormula      As Range
    Dim ColValue        As Range
    Dim RowValue        As Range
    Dim Shp             As Shape
    Dim ws              As Worksheet

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    On Error Resume Next

    For Each ws In Worksheets
        With ws
             'Find the last used cell with a formula and value
             'Search by Columns and Rows
            On Error Resume Next
            Set ColFormula = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
            Set ColValue = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, _
            LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
            Set RowFormula = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
            Set RowValue = .Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
            On Error GoTo 0

             'Determine the last column
            If ColFormula Is Nothing Then
                LastCol = 0
            Else
                LastCol = ColFormula.Column
            End If
            If Not ColValue Is Nothing Then
                LastCol = Application.WorksheetFunction.Max(LastCol, ColValue.Column)
            End If

             'Determine the last row
            If RowFormula Is Nothing Then
                LastRow = 0
            Else
                LastRow = RowFormula.Row
            End If
            If Not RowValue Is Nothing Then
                LastRow = Application.WorksheetFunction.Max(LastRow, RowValue.Row)
            End If

             'Determine if any shapes are beyond the last row and last column
            For Each Shp In .Shapes
                j = 0
                k = 0
                On Error Resume Next
                j = Shp.TopLeftCell.Row
                k = Shp.TopLeftCell.Column
                On Error GoTo 0
                If j > 0 And k > 0 Then
                    Do Until .Cells(j, k).Top > Shp.Top + Shp.Height
                        j = j + 1
                    Loop
                    If j > LastRow Then
                        LastRow = j
                    End If
                    Do Until .Cells(j, k).Left > Shp.Left + Shp.Width
                        k = k + 1
                    Loop
                    If k > LastCol Then
                        LastCol = k
                    End If
                End If
            Next

            .Range(.Cells(1, LastCol + 1), .Cells(.Rows.Count, .Columns.Count)).EntireColumn.Delete
            .Range("A" & LastRow + 1 & ":A" & .Rows.Count).EntireRow.Delete
        End With
    Next

    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

End Sub
第二次尝试


将所有数据复制到一个全新的文件中并保存。

您有数据透视表吗?没有-没有数据透视表所以除了两张表,您有15*(100*25)+9000*100+11000*5个单元格,可能与公式或其他内容一起使用。这只是少了一百万个单元,所以你的“丢失”10MB平均每个单元只能允许10字节,这对我来说似乎是合理的。我没有这样想。对我来说有道理。谢谢。你有数据透视表吗?没有-没有数据透视表所以除了两张表,你有15*(100*25)+9000*100+11000*5个单元格在使用,可能是公式之类的。这只是少了一百万个单元,所以你的“丢失”10MB平均每个单元只能允许10字节,这对我来说似乎是合理的。我没有这样想。对我来说有道理。谢谢