ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Make my vba wait? (https://www.excelbanter.com/excel-programming/429662-make-my-vba-wait.html)

Emma Hope

Make my vba wait?
 
Hi all,

I have a VBA query which refreshes a workbook and then saves it, then it
changes a particular cell value and then saves it somewhere else.

Unfortunately, the first save hasn't finished before it changes the
particular cell value, so the first save is incorrect.

How can i make the vba understand i want it to wait until the previous line
of code has finished before starting the next bit?

Thanks
Emma

joel

Make my vba wait?
 
Try this

'refresh query
DoEvents

"Emma Hope" wrote:

Hi all,

I have a VBA query which refreshes a workbook and then saves it, then it
changes a particular cell value and then saves it somewhere else.

Unfortunately, the first save hasn't finished before it changes the
particular cell value, so the first save is incorrect.

How can i make the vba understand i want it to wait until the previous line
of code has finished before starting the next bit?

Thanks
Emma


[email protected]

Make my vba wait?
 
Hi
Put in

DoEvents

after the saves. Handy if you have anything updating the screen (e.g
charts or cell values) within code.
regards
Paul

On Jun 11, 12:15*pm, Emma Hope
wrote:
Hi all,

I have a VBA query which refreshes a workbook and then saves it, then it
changes a particular cell value and then saves it somewhere else.

Unfortunately, the first save hasn't finished before it changes the
particular cell value, so the first save is incorrect.

How can i make the vba understand i want it to wait until the previous line
of code has finished before starting the next bit?

Thanks
Emma



Emma Hope

Make my vba wait?
 
this works fine after the save but not with the refresh.....


" wrote:

Hi
Put in

DoEvents

after the saves. Handy if you have anything updating the screen (e.g
charts or cell values) within code.
regards
Paul

On Jun 11, 12:15 pm, Emma Hope
wrote:
Hi all,

I have a VBA query which refreshes a workbook and then saves it, then it
changes a particular cell value and then saves it somewhere else.

Unfortunately, the first save hasn't finished before it changes the
particular cell value, so the first save is incorrect.

How can i make the vba understand i want it to wait until the previous line
of code has finished before starting the next bit?

Thanks
Emma





All times are GMT +1. The time now is 10:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com