Code Not Running In Sequence (Connection Refresh)

HomeTek

New Member
Joined
Jan 27, 2017
Messages
42
Office Version
  1. 365
Platform
  1. Windows
I have some code which does not seem to run in order. Specifically the "Test Value" line. Individually all parts of the code work fine, however the "Test Value" part always runs last no matter where it is placed.

The below code is an isolated simplified version of my code just for testing purposes.

I have turned off background refresh in the connections properties. I have also tried adding a "DoEvents" function after each line but to no avail.

Any more ideas at all please?

Thanks


VBA Code:
Sub Update Queries()

MsgBox ("Click okay to start."), vbOKOnly, "Test Box"

Application.ScreenUpdating = False

ActiveWorkbook.Connections("Raw Data 1").Refresh

Range("A1").Value = "Test Value"

MsgBox "Test message"

ActiveWorkbook.Connections("Raw Data 2").Refresh

End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi, I think because your code turns off screen updating (Application.ScreenUpdating = False) you will find that it literally does exactly that - will not update the screen. So in other words, the value in cell A1 is really updated, but you don't see it until later on when the screen updates (probably after the entire macro runs, basically).
 
Upvote 0
Hi, I think because your code turns off screen updating (Application.ScreenUpdating = False) you will find that it literally does exactly that - will not update the screen. So in other words, the value in cell A1 is really updated, but you don't see it until later on when the screen updates (probably after the entire macro runs, basically).
I somehow never even noticed that was left in there even after I stripped the code down. It was remnant of some old code that I was making use of. Weird thing is if someone else asked me about the same problem I probably would have seen it in their code straight away.

Thanks ever so much.
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,772
Members
449,049
Latest member
greyangel23

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