Excel 2003 file gets 25% bigger after changing TP source with VBA

B

Bobby

Could someone tell me why is the file is getting bigger?

This is my code:

Sub test()

Dim pt As PivotTable
Dim ws As Worksheet
tmp = ""
tmp1 = ""

Application.EnableEvents = False
Application.DisplayAlerts = False
Application.EnableEvents = False

For Each ws In ActiveWorkbook.Worksheets
Range("C12").Select
For Each pt In ws.PivotTables
tmp = pt.SourceData
tmp1 = Replace(tmp, "2011-2012", "2012-2013")
'MsgBox ws.Name
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:=tmp1

ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False

tmp = ""
tmp1 = ""
Sheets(ws.Name).Select

Next pt
Next ws
Application.Calculation = xlAutomatic
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top