VBA: Taking text typed into an Input Box and pasting it into a specific cell

  • Thread starter Thread starter cparaske
  • Start date Start date
C

cparaske

I've been trying to take information typed into an input box and havin
Excel then paste it into a specified cell on a worksheet. Does anyon
know what the code to do this is?

Literally can't get past:
nameses=inputbox("X","X"
 
one way:

Dim nameses As String
nameses = InputBox("X", "X")
Sheets("Sheet1").Range("A1").Value = nameses
 
I've been trying to take information typed into an input box and having
Excel then paste it into a specified cell on a worksheet. Does anyone
know what the code to do this is?

Literally can't get past:
nameses=inputbox("X","X")

If you'll accept anything, including the user cancelling the input box,

SomeWorkbook.SomeWorksheet.SomeRange.Value = InputBox("Prompt", "Title")

If you wanted the entry made in cell X99 on the active worksheet,

ActiveSheet.Range("X99").Value = InputBox("Prompt", "Title")

If you want to force the user to make a nontrivial entry, it's a bit more work.


Dim resp As Variant

Application.EnableCancelKey = xlDisabled

Do
resp = Application.InputBox("Prompt", "Title", , , , , , 3)
If resp = False Or resp = "" Then MsgBox "Must enter something!", , "Title"
Loop While resp = False Or resp = ""

ActiveSheet.Range("D3").Value = resp

Application.EnableCancelKey = xlInterrupt
 
Back
Top