A question about VBA Code Processing?

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
519
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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,216,207
Messages
6,129,508
Members
449,512
Latest member
Wabd

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