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.
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.