Slow code

TorontoNewf

New Member
Joined
Nov 14, 2016
Messages
20
Greetings,

I have the following code which is REALLY

Code:
For Each pi In pt.DataPivotField.PivotItems    
      pi.Caption = Pi.Caption & " "
Next pi

How do I make this faster?
Is there something that I am missing here?

Thanks,
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Maybe oversimplifying but you could try:

Code:
Application.ScreenUpdating = False

For Each pi In pt.DataPivotField.PivotItems    
      pi.Caption = Pi.Caption & " "
Next pi

Application.ScreenUpdating = True
 
Upvote 0
I hadn't used this, as it was not really a complex macro.
Nonetheless, I tried it this morning with the suggestion, and there is no doubt - it was faster.
However, even without the ScreenUpdating, Excel itself was much faster this morning.

I did get Excel 2016 installed last week, and
my machine DID get a reboot over the weekend,
so perhaps that's all that needed to be done.
Automatic updates always seem to be monitored.

O happy day!

That being said, I do thank you for your input.

Cheers,
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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