VBA Optimisation

James Burger

New Member
Joined
Jun 10, 2014
Messages
31
Hi All,

I have this VBA code line but about 60 of them one below the other and refreshes the pivot after each line I think:

Line 1 - Sheets("Sheet1").PivotTables("PivotTable1").PivotFields("Location").CurrentPage = Sheets("Sheet1").Range("C4").Text
....
Line 60 - Sheets("Sheet1").PivotTables("PivotTable1").PivotFields("Size").CurrentPage = Sheets("Sheet1").Range("C444").Text


Is there a way to turn refresh off before the code is run and then turn it back on at the end of the code please?

Many thanks for your help.

JB
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Sure - like this:

Code:
With Sheets("Sheet1").PivotTables("PivotTable1")
    .ManualUpdate = True
.PivotFields("Location").CurrentPage = Sheets("Sheet1").Range("C4").Text
....
.PivotFields("Size").CurrentPage = Sheets("Sheet1").Range("C444").Text
.ManualUpdate = False
End With
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,780
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top