Running VBA code from a button, the macro list, or VBA form

PeterM3532

New Member
Joined
May 8, 2013
Messages
1
Hello - I have a large spreadsheet with lots of pivot tables and data, and wrote a long VBA program that configures the pivot tables based on user selections which are made in a VBA form. The user selections are also stored in a worksheet within the file.

I ran the code from the VBA form, and it takes forever to run - about 20 minutes. If I go to the Macro button in the ribbon and run the code, it still takes about 20 minutes (I would expect that - it's the same code).

However, if I create a button control on my worksheet and link the same macro to this button, it runs in 4 seconds.

I optimized the heck out of this code, so I expect it to run fast, but this makes absolutely no sense that the same code would run at such different speeds depending on how I trigger it.

Has anyone ever seen anything like this before? I am running Excel 2010 on Win XP, with an i5 processor and 3GB of RAM.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,214,905
Messages
6,122,172
Members
449,071
Latest member
cdnMech

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