![]() |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
Thanks
I have never used macros. I dont know how to delete what appear to be empty cells. |
![]() |
Tags |
excel 2016, size, workbook |
|
![]() |
||||
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 |
![]() |
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 |