A question about VBA Code Processing?

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
558
Office Version
  1. 365
Platform
  1. Windows
Hi All,

My excel/vba/PQ model is quite large and heavily coded.

Often I find that parts of the VBA are missed. What I have found is the code is missed because the system is doing other processors.

In an attempt to fix this, I have started putting Application.Wait Now + Timevalue(whatever) at critical points. Tis has definitely helped the issue.

Since I have not been exposed to such a large model, I am wondering if putting in "Wait" statements like this is common place for large models, or am I putting a band aid on a bigger problem?

Looking forward to hearing your opinions.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You will no doubt receive better/more qualified opinions than mine; the number of occasions I've had code running over itself is limited. That said, and without some example code to recreate, my only input would be to look at DoEvents and/or Application.Ontime. Basically .Wait is a guess at how long we need to wait, and if you can test until something is done would likely be quicker.

Mark
 
Upvote 0
I bet your issue is with asynchronous refreshes. I seem to recall you can set a property of a query according to your needs. For example, the Refresh method of "regular" (old style) queries has an async argument.
 
Upvote 0

Forum statistics

Threads
1,224,905
Messages
6,181,663
Members
453,059
Latest member
jkevin

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