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:
- InputBox takes several arguments:
- 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.
Training Video on how to use the Inputbox in VBA: