Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Running Macros in the Background.
Written by Allen Wyatt (last updated December 19, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
When you run a macro in Excel, the program turns its full attention to completing the macro. (Sounds almost anthropomorphic, doesn't it?) This means that if the macro does quite a bit of heavy-duty processing of your data, it can seem as if your system has "locked up" during the processing of the macro.
Rest assured that the macro processing is only affecting Excel, however. You can open a different application and work within it while the macro chunks away in Excel in the background. Of course, the attention being paid to the macro by your system will probably slow down the response of the other program, but this depends on the version of Windows you are using on your system. The reason? Sharing of resources requires a process known as multitasking. Different versions of Windows handle multitasking in different ways.
You may wonder how you can do other work in Excel while the program is busy running a macro. Easy—just open another instance of Excel (run it again from your Start menu) and do some other work. All you need to do is make sure that you don't try to work on the same workbook (or workbooks) being utilized by the macros in your first instance of Excel.
Another way to do a bit of work is to modify your macro just a bit. Chances are good that if your macro is running for a long period, it is due to it executing a loop of some type. By adding within the loop the DoEvents command, the macro will suspend execution temporarily and hand back control to the user's processes. So if you've pressed a key, clicked the mouse, or started to type something, DoEvents takes notice and performs whatever tasks are required to handle what you want done. When all user input has been serviced, the macro continues happily on its way.
Adding DoEvents slows down your macro somewhat, but it does allow you to continue working a bit. (Understand that Excel will still be sluggish; your macro does take resources to run.) Adding DoEvents can also provide an opportunity to break out of the macro (using Ctrl+Break) in a controlled manner.
Remember, though, that you can only figure out what works best in your situation by testing (and more testing).
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8971) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Running Macros in the Background.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
When sharing workbooks with others, you may find that the macros in those workbooks may not work as you expect. This tip ...
Discover MoreBesides the regular way of displaying formulas, Excel can also display them using what is called R1C1 format. If you are ...
Discover MoreWhen using a macro to process information in a worksheet, you may want that macro to figure out how many columns are ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-12-20 03:07:23
Philip
Note : running multiple instances of Excel (or any app) on a Mac is NOT possible ...
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments