Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2020, 06:51 AM
NoSparks NoSparks is offline size of Excel workbook Windows 10 size of Excel workbook Office 2010
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Excessive formatting.

Happens when formatting gets applied to entire rows, entire columns or all cells of a sheet.
In particular the Apple date & ginger and the Apple pear & apricot sheets which have some kind of formatting applied all the way to cell "IV65536" (that's row 65536 column 256) but the last used cells are actually "F22" and "H24".
Need to delete the rows and columns beyond those actually being used.



After running this "Lose That Weight" macro to automatically do this for all sheets in the workbook the saved size was around 33KB.
Code:
Sub LoseThatWeight()
' saved from post #4 of:
' https://www.mrexcel.com/forum/excel-questions/961348-how-get-rid-ghost-rows-without-saving-file.html

    Dim x As Long, Lastrow As Long, LastCol As Long

    Application.ScreenUpdating = False

    On Error Resume Next

    For x = 1 To Sheets.Count
        With Sheets(x)
            Lastrow = .Cells.Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, _
                          LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
            LastCol = .Cells.Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, _
                          LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
            .Range(.Cells(1, LastCol + 1), .Cells(Rows.Count, Columns.Count)).Delete
            .Range(.Cells(Lastrow + 1, 1), .Cells(Rows.Count, Columns.Count)).Delete
        End With
    Next x
    On Error GoTo 0
    Application.ScreenUpdating = True
End Sub
Reply With Quote
  #2  
Old 08-30-2020, 10:15 AM
ggeoff ggeoff is offline size of Excel workbook Windows 10 size of Excel workbook Office 2016
Novice
size of Excel workbook
 
Join Date: Nov 2013
Location: Wiltshire UK
Posts: 28
ggeoff is on a distinguished road
Default

Thanks


I have never used macros. I dont know how to delete what appear to be empty cells.
Reply With Quote
Reply

Tags
excel 2016, size, workbook



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I copy a workbook to another workbook and keep the formatting within the new workbook excelforsue Excel 3 09-15-2020 03:37 AM
size of Excel workbook Export Project in Excel Workbook codeghi Project 3 09-28-2016 11:32 AM
How to add attached excel workbook with hyperlink in the same workbook lynchbro Excel Programming 0 02-24-2015 01:29 PM
Shared Excel workbook eguru2 Excel 0 07-12-2011 12:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:14 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft