Notifications
Clear all

Como reduzir o tamanho de uma planilha?

4 Posts
4 Usuários
0 Reactions
5,043 Visualizações
 Eron
(@eron)
Posts: 103
Estimable Member Admin
Topic starter
 

Quando você recebe um arquivo, o tamanho foi em Kbs ou não mais de 1 Mb. Mas quando você fecha ele, e salva sua pasta de trabalho, descobre que o tamanho do arquivo foi inchado para 3, 100 vezes. É possível, isso acontece no Excel.

Como resolver? Simples: nem sempre você ocupa todas as células em uma planilha, então por que ter elas dentro da sua pasta de trabalho, ocupando espaço?

Primeiro Passo: Abra sua planilha e digite "Ctrl + End". Automaticamente o Excel vai apresentar a ultima célula realmente utilizada. Quanto mais além desta sua " última célula realmente utilizada " maior será o tamanho do arquivo pois há mais células desnecessárias do que a pasta de trabalho precisaria ter.

Segundo Passo: Apague todas as linhas e colunas além da “última célula realmente utilizada " em cada planilha da sua pasta de trabalho. Se houver planilhas e grandes conjuntos de dados, você pode usar a macro VBA a seguir mencionadas.

Option Explicit
Sub SHRINK_EXCEL_FILE_SIZE()

    Dim WSheet As Worksheet
    Dim CSheet As String 'New Worksheet
    Dim OSheet As String 'Old WorkSheet
    Dim Col As Long
    Dim ECol As Long 'Last Column
    Dim lRow As Long
    Dim BRow As Long 'Last Row
    Dim Pic As Object
   
    For Each WSheet In Worksheets
        WSheet.Activate
         'Put the sheets in a variable to make it easy to go back and forth
        CSheet = WSheet.Name
         'Rename the sheet to its name with _Delete at the end
        OSheet = CSheet & "_Delete"
        WSheet.Name = OSheet
         'Add a new sheet and call it the original sheets name
        Sheets.Add
        ActiveSheet.Name = CSheet
        Sheets(OSheet).Activate
         'Find the bottom cell of data on each column and find the further row
        For Col = 1 To Columns.Count 'Find the actual last bottom row
            If Cells(Rows.Count, Col).End(xlUp).Row > BRow Then
                BRow = Cells(Rows.Count, Col).End(xlUp).Row
            End If
        Next
       
         'Find the end cell of data on each row that has data and find the furthest one
        For lRow = 1 To BRow 'Find the actual last right column
            If Cells(lRow, Columns.Count).End(xlToLeft).Column > ECol Then
                ECol = Cells(lRow, Columns.Count).End(xlToLeft).Column
            End If
        Next
       
         'Copy the REAL set of data
        Range(Cells(1, 1), Cells(BRow, ECol)).Copy
        Sheets(CSheet).Activate
         'Paste Every Thing
        Range("A1").PasteSpecial xlPasteAll
         'Paste Column Widths
        Range("A1").PasteSpecial xlPasteColumnWidths

        Sheets(OSheet).Activate
        For Each Pic In ActiveSheet.Pictures
            Pic.Copy
            Sheets(CSheet).Paste
            Sheets(CSheet).Pictures(Pic.Index).Top = Pic.Top
            Sheets(CSheet).Pictures(Pic.Index).Left = Pic.Left
        Next Pic
        Sheets(CSheet).Activate
       
         'Reset the variable for the next sheet
        BRow = 0
        ECol = 0
    Next WSheet
   
     ' Since, Excel will automatically replace the sheet references for you on your formulas,
     ' the below part puts them back.
     ' This is done with a simple replace, replacing _Delete with nothing
    For Each WSheet In Worksheets
        WSheet.Activate
        Cells.Replace "_Delete", ""
    Next WSheet
   
    'Roll through the sheets and delete the original fat sheets
    For Each WSheet In Worksheets
        If Not Len(Replace(WSheet.Name, "_Delete", "")) = Len(WSheet.Name) Then
            Application.DisplayAlerts = False
            WSheet.Delete
            Application.DisplayAlerts = True
        End If
    Next
End Sub

Fonte: http://www.excelitems.com/2010/11/shrin ... -size.html

 
Postado : 16/12/2011 11:00 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Muito boa a dica do Eron!!!!

Tbem pode ser feito via software com um programa trial File Minimizer Suite ..... serve pra Office / PDF / Imagem
http://www.balesio.com/fileminimizersuite/eng/index.php

 
Postado : 16/12/2011 11:54 am
(@brunoicq)
Posts: 0
New Member
 

Esta em ingles, mas é muito util

http://www.vbaexpress.com/kb/getarticle.php?kb_id=83

 
Postado : 16/10/2015 1:37 pm
(@pfarias)
Posts: 0
New Member
 

Postei um arquivo a poucos dais que reduz o tamanho do arquivo e quando compactado muito mais!

http://www.planilhando.com.br/forum/viewtopic.php?f=21&t=17751

 
Postado : 20/10/2015 9:50 am