ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro asking for input (https://www.excelbanter.com/excel-programming/322479-macro-asking-input.html)

jerry chapman[_2_]

Macro asking for input
 
How can I write a macro that asks for and read a user supplied date?



sebastienm

Macro asking for input
 
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
"jerry chapman" wrote:

How can I write a macro that asks for and read a user supplied date?




Jim May

Macro asking for input
 
Range("B5").Formula = InputBox("Enter Date")
works for me.

"jerry chapman" wrote in message
.. .
How can I write a macro that asks for and read a user supplied date?






All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com