Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company.
Learn more about Allen...
The macro language (VBA) provided with Excel is quite powerful. This means that you can do some pretty intense (and impressive) tasks with the language. Some tasks might take quite a while to complete. The problem is that some users may think their computer has hung unless there is some on-screen indication that the macro is running.
There are two ways that you can approach a solution to such a task. The first (and simplest) option is to use the status bar to indicate the progress of your macro. For instance, you could add some code to your macro by which it determines the percentage of completion. Once you have a percentage in hand (let's say it is stored in the xPctComp variable), you simply add the following line to your macro:
Application.StatusBar = "Portion completed: " & _ Format(xPctComp, "##0.00%")
Such a line could be added within the main body of your macro, for instance within whatever loop you have that controls processing. When the macro is just about done, you should add a line that clears the status bar, such as the following:
Application.StatusBar = ""
The other way to create a progress indicator is to use some sort of a dialog box that displays a "fuel gauge" indicator as to the percentage complete. There are numerous implementations of such a concept already available on the Web. A good representative of this approach is found at John Walkenbach's site:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2496) applies to Microsoft Excel 97, 2000, 2002, and 2003.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!