VBA: Wait command that would allow data to be fully imported before continuing script

eques247

New Member
Joined
Oct 22, 2015
Messages
7
Hello,

I'm trying to find a command that would temporarily pause my script and allow data from a database to be fully imported before continuing the script. It takes a few seconds for it all to be imported. My code doesn't account for this and it continues to run other subs that are based off this data so this ultimately causes my script to crash.

I've tried using these two commands but all they did was temporarily stop anything from running (including the data that is being imported) which causes the same issues as before. At the bottom is a gist of what I want my code to do

Code:
Sub()
Application.Wait (Now + TimeValue("0:00:5"))
End Sub

Code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub()
Sleep 500

End sub

Here is a general idea of what I want my code to do
Code:
Sub()

-apply user defined settings

Application.Calculate  [COLOR=#0000ff]'data starts to be imported from database[/COLOR]


-pause for a few seconds    [COLOR=#0000ff]'allows data to be fully imported[/COLOR]

-call other subs

End sub

Thanks!!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Here is a description about how the data from the database is retrieved. Before the program is run, the user defines the two variables he would want to calculate by placing them into specific cells. Once the user starts the program and it reaches the calculate command, it applies the two variables into the formula and then retrieves the data from the database based on those conditions. The data that is retrieved is then placed into the worksheet.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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