Pausing Macros for User Input

by Allen Wyatt
(last updated July 7, 2018)


For those who have been around spreadsheet programs for quite some time, you may remember the old {?}~ command that was available in Lotus 1-2-3. This command allows you to pause the macro while the user enters data in the spreadsheet.

Excel doesn't include the same capability, but it does have ways that you can prompt the user for input. The two primary methods are these:

  • MsgBox function. This function displays a dialog box and a set of buttons. When the user clicks on a button, an integer value is returned that indicates the button clicked. Your program can then take action based on the value returned.
  • InputBox function. This function displays a dialog box and allows the user to type a response. Whatever the user types is returned as a string to the macro.

Both of these functions have been discussed in other issues of ExcelTips; I won't go over them again here. Based on the user's input, you can modify what the macro does in any way desired. The only drawback to the functions is that they only return a single, discrete piece of data. In other words, they aren't designed to allow the user to input a range of cells and then continue processing. For instance, if you wanted to ask the user to provide five values destined for five cells, you would need to present an InputBox five times, depositing the user's responses into the desired cells one after the other.


If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9515) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365.

Author Bio

Allen Wyatt

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. ...


Using Stored Views

After creating different views of your worksheet data, you can display those views by simply selecting which one you want ...

Discover More

Disappearing Status Bar

Ever had your Excel status bar disappear unexpectedly? Here's some ideas on why this may be happening.

Discover More

Deleting Shortcuts

Windows allows you to easily create any number of shortcuts you desire. If you want to get rid of those shortcuts at some ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Editing Macros

Even if you do nothing but record macros, sooner or later you will have a need to edit what you record. Here's how to get ...

Discover More

Writing a Macro from Scratch

Creating macros can help extend what you can do in Excel. If you work with macros, you know that creating macros from ...

Discover More

Understanding Subroutines

When developing macros, you can create subroutines. This is a great way to reuse common code and make your programming ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 3?

2017-01-05 04:59:50

sunil kumar verma

I would like to known excel tips.

2016-07-27 15:54:46

There is a fourth option, Michael: Use the search box at the upper-right corner of any page on this site.

This site contains every single tip ever published in 17+ years of weekly publishing about Excel. That's a lot of tips--about 1,800 of them or so at last count. I try very hard not to duplicate information, so the search function is a very handy function to keep in mind.

Sorry for any frustration!


2016-07-27 13:17:00

Michael Heavener

I'm new to your tips, so instead of telling me you've covered this before, I suggest several options.

1. Don't whet my appetites and dash my hopes. Just don't bring up the topic in the newsletter.

2. Repeat the whole tip for those of us who haven't seen it before. People who have will understand and move on.

3. Provide links to the tips so we don't get frustrated.

Michael Heavener

2016-07-27 12:09:12


On his site, "Chip" Pearson also gives some very interesting means to wait for an user input :

2015-05-27 09:13:44

Glenn Case


Allen has a search box at the top of each tip page; you can use those to search for the terms of interest, and each will typically get you several related tips. For instance, a search for "MsgBox" produces 10 pages of related tips. Thus, it's not surprising that Allen does not necessarily link to these directly.

Hope this helps you find what you're after. If it does not, feel free to ask a specific question in the comment section of a related tip, or select the "Ask an Excel Question" link on the righthand side of this page under "Helpful Links" if your question is unrelated to the tip.

2015-05-26 19:05:44


It would have been helpful if you'd at least linked the previous articles for those of us who don't read your blog regularly and simply found your post while looking for the solution!

2014-09-24 13:47:00

Mohammed Khan

Thanks for this tip.
Can you show a full macro before and after
"UserForm1.Show vbModeless

I wil be grateful. Best regards.

2013-12-28 12:14:42

Bill Meyer

To pause a macro and allow users to enter data directly into a worksheet simply create a user form (UserForm1). Then in the macro put:

UserForm1.Show vbModeless
Do While UserForm1.Visible

When the user form is closed the macro continues execution at the next statement

This Site

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.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.