0

I have two VBA scripts that execute external data queries, I need information from the first to determine the guidelines for the second. However, when I set them up as concurrent calls in a VBA script, the second hangs because the screen has not finished updating for the second to look for it's criteria.

I'm looking for either a way to get the data from the query during the VBA script process of the first, or get the screen update to complete before the second VBA script begins.

Luuklag
  • 3,897
  • 11
  • 38
  • 57

2 Answers2

0

I'm not sure I understand your question, but, if I do, maybe your easiest solution would be to create a global boolean variable, say Macro1Complete, set it to False and have it set to true at the end of the first macro.

Then, before starting the second macro, you check for Macro1Complete = TRUE, or else sleep for a second or so.

I apologize if I don't understand the question, though.

Or, maybe this is what you're looking for?

Good luck!!

Community
  • 1
  • 1
John Bustos
  • 19,036
  • 17
  • 89
  • 151
0

have you tried something like this :

Sheets(1).calculate 'or usedrange, or range whatever.calculate, to calculate data
'add a workbooks("name of WB").sheets..., if you work on opened wb

doevents 'will update screen

macro_next 'launch the next macro
Patrick Lepelletier
  • 1,596
  • 2
  • 17
  • 24