Vba input box and display in cell in Excel

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub InputBoxExample()
  3. ActiveSheet.Range("G2") = InputBox("Enter a test value", "InputBox Example")
  4. End Sub

Result after Macro execution:

a) Line 3 displays a prompt as shown below. The value entered by user is then recorded in cell "G2".

excel vba input box and display in cell

b) Enter a Test value (5 in the example below). Click OK.

excel vba input box and display in cell

c) Cell G2 is updated with value entered by user.

excel vba input box and display in cell

 

You can find similar Excel Questions and Answer hereunder

1) Here an explanation about list box and how to control list boxes in Excel VBA

2) How to do worksheet protection with VBA in Excel

3) One of my formulas has returned an error - how can I trace the error to fix it?

4) Highlight row of selected cell in Excel

5) How do I copy a Table from one location to another and retain all formulas, formats and columnwidths?

6) How can I prevent users from seeing / accessing my macro code?

7) Import txt file in Excel

8) How to read a value from a cell in vba in Excel

9) Can I add a small chart to Table data to make it visually appealing and easy to interpret?

10) How can I ensure that user enters only certain acceptable values in an input cell?

 

Here the previous and next chapter