VBA Runtime Differences

BLBuck

New Member
Joined
May 11, 2018
Messages
1
I have written a VBA that will group items in a worksheet if certain criteria are met and collapse those groups. I have assigned a form button to run this macro so it was easier to test in different situations to make sure it would always work - and everything is going great with the actual macro. My issue is with the run time speed. When I click on the button, the macro runs in about half a second. When i go through Developer->Macros->[Macro Name], it takes about 10 seconds to run, and I have no idea why there is a difference. They both reference the same set of code, but its much more efficient when the button is pressed. My issue is that I have to run this for ~100 sets of data that will be cycled through using another macro and a large for loop, which runs at the slower 10 second speed.

I don't think the code itself is a problem, as it runs quickly when the associated button is pressed. What is there about pressing a button to run the macro would make it faster? (or, conversely, Macros->[Macro Name] cause it to run slower)

I have tried to turn off screen updating, calculations, etc, but they do not have any noticeable effect on the speed.

Using Excel 2010 if it makes a difference.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,223,606
Messages
6,173,323
Members
452,510
Latest member
RCan29

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