Excel vba

vbacoder12

New Member
Joined
Sep 4, 2024
Messages
24
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
I have a 2 part question.
So i am running a runthemall sub using application.run for my macros. But they all appear to be running at the same time. Is there a way to ensure each one doesn't run before the one running is finished.

Question 2. I also have a refreshall query which once the tables are updated I would lie the queries to be deleted making it a table. I have tried this and it always seems like the queries are deleted before all tables are refreshed.

Any thoughts on either of theses
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
If you set your subs up like the following, Excel will run the first sub, then the second sub, then the third sub, etc. etc.
Excel will wait for the first sub to complete before going to the next.

VBA Code:
Option Explicit

Sub runsubs()
    
    subname1
    subname2
    subname3
    etc
    etc
    
    
End Sub
 
Upvote 0
If you set your subs up like the following, Excel will run the first sub, then the second sub, then the third sub, etc. etc.
Excel will wait for the first sub to complete before going to the next.

VBA Code:
Option Explicit

Sub runsubs()
   
    subname1
    subname2
    subname3
    etc
    etc
   
   
End Sub
 
Upvote 0
Do you think I should make each until query refresh it's own sub or can I make the first sub refresh all and my final sub a delete all queries
 
Upvote 0
Not certain I understand your question.
"Refresh" ... generally there will not be a need to 'refresh' anything. The macros will run in the order you place them.

Another method is to run your first macro but at the very bottom of the first macro, type in the name of the second macro to run. When the first macro is complete
it will 'read' that last line and go to the next macro.

At the bottom of the second macro, you can put the name of the third macro and the process begins again with the second macro opening the third macro and running it.

What do you mean by deleting all queries ?
 
Upvote 0
Not certain I understand your question.
"Refresh" ... generally there will not be a need to 'refresh' anything. The macros will run in the order you place them.

Another method is to run your first macro but at the very bottom of the first macro, type in the name of the second macro to run. When the first macro is complete
it will 'read' that last line and go to the next macro.

At the bottom of the second macro, you can put the name of the third macro and the process begins again with the second macro opening the third macro and running it.

What do you mean by deleting all queries ?
My first query is basically refreshing all queries. Then I have some other things run. My last step is to delete the queries so that the data is just on the sheet without a data connection. It's delQueries
 
Upvote 0
If I understand your explanation ... you could delete the query ... but what do you do if the query needs to be run again ? Recreate your queries ?

Another approach might be to copy your updated data to a different sheet that doesn't have any queries. You would be copy/paste values only.
Then you could leave the queries in place for running at a later time.

???
 
Upvote 0
If I understand your explanation ... you could delete the query ... but what do you do if the query needs to be run again ? Recreate your queries ?

Another approach might be to copy your updated data to a different sheet that doesn't have any queries. You would be copy/paste values only.
Then you could leave the queries in place for running at a later time.

???
Queries are only needed this one time. Won't need to refresh data. I have code that will deleted. Biggest issue is it would run before the queries loaded and the data wouldn't refresh. I'll try the runsubs() and see if it works
 
Upvote 0
Solution
Queries are only needed this one time. Won't need to refresh data. I have code that will deleted. Biggest issue is it would run before the queries loaded and the data wouldn't refresh. I'll try the runsubs() and see if it works
Issue was i had enable background data check n was causing queries to refresh out of order
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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