Macro asking for input

  • Thread starter Thread starter jerry chapman
  • Start date Start date
J

jerry chapman

How can I write a macro that asks for and read a user supplied date?
 
You could use an InputBox. There are 2 different ones , one is from excel
(Application.ImputBox) , the other one is from vba (InputBox). The first one
is , i believe, more interesting as you tell what kind of value you ask for :
Sub test()
Dim res As String
res = Application.InputBox("Select a range", "My Input", , , , , , 2)
'above, the last param 2 means we ask for a String
If res = "False" Then Exit Sub 'user clicked cancel
'else continue to process
MsgBox "you have entered: " & res
End Sub

Check the online help to get more input on how to use it (ask the user to
select a range, to enter a number, ...)

Regards,
Sebastien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top