2017-12-14 6 views
0

私は非常に大きなワークブックを持っています(約30 MB)。私はこれがいくつかの人に比べてかなり小さいことを認識していますが、数学はちょうど足りないようです。Excelブックのサイズがかなり大きい

  • 合計19枚あり、約15-20の名前付き範囲があります。 (100行と25列の下)は、4つの

  • 2つは約テーブル(最小書式)である

  • すべてが、これらのシートの4つの小使用範囲を有します。別々のファイルからペーストされたデータを含む35,000行×40列。 20 MB。

  • 他のシートはテーブルではなく、フォーマットされていません。 9000行100列、11000行×5列。

私の質問は次のとおりです。追加の10 MBはどこから来ていますか?

編集:

私はすでに最低限に各シート上の私の使用範囲ダウンをカットしていることに注意してください。また、重要なVBAを含む会社のテンプレートからブックがコピーされますが、そのファイルは1 MB未満です。

+0

ピボットテーブルはありますか? –

+0

いいえ - ピボットテーブルがありません – Spencer

+0

https://superuser.com/questions/431118/bloated-excelfile-with-negligible-dataが重要です。 – pnuts

答えて

2

Excelは最後の行と最後の列番号を正しく管理しないため、異なるファイルのデータを1つにコピーすると、通常この問題が発生するため、空のセルの値を格納するために大量のデータを使用します。

以下を試してください。

第一は、最大COLと行番号をリセットするには、以下のエクセル国会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 

第二ブランドの新しいファイルに

コピーしたデータのすべてを試してみて、保存します。

関連する問題