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


Copying Formats to a New Worksheet

Do you want to copy formats from one worksheet to another? You can do so easily by using the Format Painter. It even ...

Discover More

Create a Template that Stops Styles from Being Added to a Document

Limiting which styles a user can use or add to a document can be a tricky task. Fortunately, Word has advanced to the ...

Discover More

Inserting the User's Name in a Cell

Need to understand who is using a particular workbook? There are a number of ways you can find out, as discussed in this tip.

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Adjusting a Path Based on System and User

It is not uncommon to set variables in a macro based on other values, such as time or date. You could also set variables ...

Discover More

Ctrl+Break Won't Work to Stop a Macro

When you need to stop a macro while it is running, you normally press Ctrl+Break. What are you to do if the keypress ...

Discover More

Calculating the Distance between the Top of the Window and Row 1

Normally Excel positions a UserForm in the center of your screen. You may want to position the form elsewhere, more ...

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 nine more than 6?

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.