Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: Using InputBox to Get Data.

Using InputBox to Get Data

by Allen Wyatt
(last updated August 23, 2016)

7

If you are developing a simple custom application in Excel, you may want to use the InputBox function to retrieve information from the user, and then place that information in a particular place in a worksheet. This can be easily done in the following manner:

UserValue = InputBox("Value to use?")
Cells(1, 1).Value = UserValue

These two lines, when inserted into a macro, prompt the user for input. This input is assigned to the UserValue variable by the InputBox function. The contents of this variable are then deposited in cell A1 of the current worksheet using the Cells method. If you prefer, you could also use the Range object to specify a location for the value, as shown here:

UserValue = InputBox("Value to use?")
Range("B3").Value = UserValue

This example deposits the value of UserValue into cell B3.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12496) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Using InputBox to Get Data.

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

MORE FROM ALLEN

Closing a Read-Only Workbook

When you create a workbook that is read-only, users can still make changes to the workbook. When they exit, they are prompted ...

Discover More

Faster Picture Displaying

If you have a document with many graphics, you know that Word can sometimes be slow in displaying all those graphics. This ...

Discover More

Scroll Wheel Doesn't Work when Editing

Using the mouse's scroll wheel can help improve how you edit information in a worksheet. Here's how to make sure that the ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Using Macros in Protected Workbooks

Having problems with using macros in a protected workbook? There could be any number of causes (and solutions) as described ...

Discover More

Resetting Default Names for New Worksheets

When you add a new worksheet to a workbook, Excel gives it a default name that consists of "Sheet" followed by a number. If ...

Discover More

Progression Indicator in a Macro

When your macro is humming along, minding its own business, a user watching the screen may not see any activity and therefore ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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 8Mpixels. 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 6 - 3?

2016-08-24 10:22:39

Gary Lundblad

Thanks Tom! I can kind of see what you mean, and I'm intrigued by the idea. I'll try to work on this angle.

Thank you again!

Gary


2016-08-23 21:14:18

Tom

Gary

You may not need to use VBA at all.
You may be able to do everything using data validation and some clever formulas.

Search the web for using named ranges and the INDIRECT function in data validation. You can design the possible range of answers for each question.
When as user responds, the next question can then be chosen based on their response.
If you hide the supporting sheets, lock all cells except the input ones, and protect the sheet and the workbook, it can be made almost idiot and tamper proof.


2016-08-23 20:09:52

Gary Lundblad

Thank you Dave- I'll check that out!

Gary


2016-08-23 18:02:28

Dave Unger

Gary, probably what you'd want to do is build a "wizard", using a MultiPage UserForm. John Walkenbach has examples of how to go about it in his books, and there are quite a few links available on the Internet - Google "vba multipage wizard"


2016-08-23 10:36:25

Gary Lundblad

I would like a macro to step someone through a series of questions, where their answers dictate the next questions asked. The answers will all be true or false, and will ultimately describe a scenario that will provide direction and then ask for appropriate information, i.e. names, amounts, address, date, etc.. As a result of the answers, only 5 at the most, and the subsequent information provided, forms would be filled out properly. Is this type of thing difficult to do in Excel using a macro. I basically want to idiot-proof the process and ensure that all pertinent information is completed, and the appropriate scenario is described. I have the series of questions and subsequent answers, but am wondering how difficult it would be to write the VBA to automate it.

Thank you!

Gary


2015-03-11 23:23:52

D P Jindal

I want to get input and want to use it in a report: where field value is the input so that the report display for a particular row(record)


2013-04-29 08:33:32

Bryan

Could be important to note here that if the ONLY thing you are using the input box for is to add a value to a cell then you don't need to bother with the intermediary variable:

Cells(1,1).Value = InputBox("Value to use?")


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
Subscribe

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.