27. VBA Tips - Inputbox

A way to ask a user of your system a question is to use an Inputbox:
Here's what we're trying to achieve:
Ask the question:
Display the answer:
Here's the code:
Explanation:
- InputBox takes several arguments:
- Prompt
- Title
- Default
- Xpos
- Ypos
- HelpFile
- Context
- In this example, we have entered:
- Prompt: "How Many Apples Do You Want?"
- Title: "Apples"
- Default: 3
- We then display the choice back to the user, but using this in a practical way, we'd trap the answer and use it for something else
- We check whether the return from the box is ""
- If "" then they've pressed the Cancel button, and we should exit.
Download sheet to practise how to use the Inputbox in VBA
Training Video on how to use the Inputbox in VBA:
| Attachment | Size |
|---|---|
| inputbox.xls | 48 KB |
»
- Nick's blog
- Add new comment
- 872 reads

Recent comments
1 day 1 hour ago
1 day 7 hours ago
1 day 12 hours ago
1 day 20 hours ago
1 day 20 hours ago
1 day 21 hours ago
1 day 21 hours ago
1 day 22 hours ago
4 days 6 hours ago
5 days 19 hours ago