macro msg box


Posted by .... on February 01, 2002 3:23 AM

how to make a msg box appear which say "plz enter today's date" then when the user enter today's day and pres ok, the date the user enter will appear on cell A1.

Posted by ,,,, on February 01, 2002 4:12 AM


You could do it with this :-

Sub Get_Todays_Date()
Dim DateInput As String
DateInput = Application.InputBox("Please enter today's date")
If DateValue(DateInput) = Date Then
[A1].Value = DateValue(DateInput)
Else
MsgBox "You must only enter today's date"
End If
End Sub


But why ask for the current date to be input?
Why not just have the macro enter the current date in A1 with a single line of code:-
[A1].value = Date




Posted by ,,,, on February 01, 2002 4:17 AM

Correction .......


The macro should be :-

Sub Get_Todays_Date()
Dim DateInput As String
DateInput = Application.InputBox("Please enter today's date")
If IsDate(DateInput) Then
If DateValue(DateInput) = Date Then
[A1].Value = DateValue(DateInput)
End If
Else
MsgBox "You must only enter today's date"
End If
End Sub