Solved

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

Posted on 2013-11-14
3
352 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 45

Accepted Solution

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

Author Closing Comment

by:GPSPOW
Comment Utility
Thanks

glen
0
 
LVL 45

Expert Comment

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

Marty - MVP 2009 to 2013
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

771 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

14 Experts available now in Live!

Get 1:1 Help Now