Pausing Macros for User Input

by Allen Wyatt
(last updated July 27, 2016)


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

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

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


Merging Formatted Data

Using the mail merge feature of Word, you can make data from Access databases accessible for your documents. How ...

Discover More

Removing Shading from Many Paragraphs

Need to format a bunch of paragraphs within your document? Word provides some very easy ways to apply the same formatting ...

Discover More

Understanding Forms

If you have ever created several documents that contain the same basic information with only a few minor differences, ...

Discover More

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!

More ExcelTips (ribbon)

Copying Named Ranges

Named ranges are a great tool to use in developing formula-heavy workbooks. You may want, at some point, to copy your ...

Discover More

Specifying a Delimiter when Saving a CSV File in a Macro

You can, within a macro, save a workbook in several different file formats that are understood by Excel. However, you may ...

Discover More

Reversing Names In Place

Do you want a way to reverse names within a cell, making them "last, first" instead of "first last?" Here's a handy macro ...

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 six more than 8?

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.