View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default defrag an excel file

It is probably better to copy the worksheets to a new wrokbook. sometimes a
workbook gets corrupted and the only solution is to move the sheets to a new
workbook.

the macro below will automatically create a new workbook and move the
worksheets. charts will not be moved and if there are references between
worksheets they probably won't get updated. You may need to update links by
going to worksheet menu Edit - Links to get the links updated.


Sub movetonew()

Workbooks.Add
Set NewWbk = ActiveWorkbook
For Each wbk In ThisWorkbook.Worksheets
wbk.Copy after:=NewWbk.Sheets(NewWbk.Worksheets.Count)
Next wbk
End Sub


"BobHankinson" wrote:

I have an Excel 2003 workbook in which I created a lot of pivot tables, all
of which I have deleted. There must be some data hidden because the file has
grown to 2.5MB and is very slow to navigate. How can I delete the hidden
tables?