Solved

How to make a VBA pause until a Refresh has completed.

Posted on 2013-11-14
3
364 Views
Last Modified: 2013-11-14
The following code will go to a tab in a spreadsheet, refresh the data and then return to the Dashboard when the refresh is finished.

The problem I am having is that the cursor returns to the Dashboard before the Refresh is finished and the user thinks he can make another selection.  When another selection is made, he either gets a warning that the refresh is still running does he want to cancel or continue with the refresh.  Or sometimes he gets a Run Time Error.

What can I add below make it so that the cursor does not go back to the dashboard until the Refresh has completed?

If Range("R1") = "Update Master Patient List" Then
                             
             ActiveWorkbook.Sheets("MeditechData").Activate
             If Not ActiveSheet.AutoFilterMode Then
                 ActiveSheet.Range("A5").AutoFilter
             End If
             Range("C1").Select
             ActiveWorkbook.RefreshAll
             ActiveWorkbook.Sheets("Dashboard").Activate
             Range("B8").Select
         End If


Thanks

Glen
0
Comment
Question by:GPSPOW
  • 2
3 Comments
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39650355
Add Application.EnableEvents = False at the start and set it to True at the end.
0
 

Author Closing Comment

by:GPSPOW
ID: 39650361
Thanks

glen
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39650376
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now