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
- 3580 reads

Can't find anywhere, need help
I have created an INPUT Box however I want the input to be placed in a range in Excel, not have a message box appear.
I have looked everyhwere for this instruction...Can you help?
inputbox
Range("A1").value = NumberOfApples
Funny thing
Thanks so much for your answer. I'm an excel expert but not a VBA wiz at all.
Funny thing happening when I do this....Depending on the number I place in the input box it will place a symbol in A1 like the forward symbol or maximze symbol?????
Sub InputBoxDemo()
NumberOfApples = InputBox("How Many Apples Do You Want?", "Apples", 3)
Range("A1").Value = NumberOfApples
End Sub
create a new forum topic, and
create a new forum topic, and add an example sheet with your problem.
The behaviour is v odd
Funny thing - Font
Check the font of cell A1 or any other thing like code or conditional formatting on that cell.