Loading
Excel.Tips.Net ExcelTips (Menu Interface)

Waiting for Update Completion

It is not unusual to create a macro that loads data from an external source (such as a database query) and then processes that data. If you create such a macro, you may notice a slight problem—Excel doesn't wait for the data refresh to complete before it begins merrily chunking away on the code that follows.

The reason for this is simple—when you refresh information in a workbook from an external source (such as an Oracle database query), Excel won't wait around. This is contrasted with internal events in Excel, which can be easily waited upon. To overcome this difference, you need to change the way you write the macros. Essentially, you need to write two separate macros. The first macro basically initiates the refresh from the external source, and the second macro is executed once the refresh is completed.

How do you know when you can run the second macro? You could do it manually after visually inspecting the worksheet to make sure everything loaded, but that ties you up. Instead, you can tie a macro to the AfterRefresh event. This event is triggered when (as its name suggests) the refresh is complete. For more information on how to use this event in your programming, visit the Microsoft Knowledge Base articles at these addresses:

http://support.microsoft.com/kb/182735
http://support.microsoft.com/kb/213187

These Knowledge Base articles are for Excel 97 and Excel 2000, but the information they contain will also work with later versions of Excel.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2612) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Related Tips:

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.