S
StargateFan
I've read and read on the archives but I'm obviously not plugging in
right search terms as I'm not familiar with the required syntax to
begin with <g>. Same with the help file.
In box code below, there is a simple error handling "On Error GoTo 0".
What can this be replaced with so that if user changes mind and clicks
cancel, the macro will just go to the last line and invoke the
"ActiveSheet.Protect"?
****************************************************
Sub RequestDateFromUser()
'
ActiveSheet.Unprotect 'place at the beginning of the code
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
Dim vResponse As Variant
Do
vResponse = Application.InputBox( _
Prompt:="Enter a start date." & vbCrLf & vbCrLf & _
"(By the way, Excel is pretty forgiving of the date
style you use when you enter that date.)", _
Title:="Health Log", _
Default:=Format(Date, "yyyy/mm/dd"), _
Type:=2)
If vResponse = False Then Exit Sub 'User cancelled
Loop Until IsDate(vResponse)
With Range("B2")
.NumberFormat = "mmm.dd.yyyy"
.Value = CDate(vResponse)
End With
ActiveSheet.Protect 'place at the end of the code
End Sub
****************************************************
Thanks! D
right search terms as I'm not familiar with the required syntax to
begin with <g>. Same with the help file.
In box code below, there is a simple error handling "On Error GoTo 0".
What can this be replaced with so that if user changes mind and clicks
cancel, the macro will just go to the last line and invoke the
"ActiveSheet.Protect"?
****************************************************
Sub RequestDateFromUser()
'
ActiveSheet.Unprotect 'place at the beginning of the code
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
Dim vResponse As Variant
Do
vResponse = Application.InputBox( _
Prompt:="Enter a start date." & vbCrLf & vbCrLf & _
"(By the way, Excel is pretty forgiving of the date
style you use when you enter that date.)", _
Title:="Health Log", _
Default:=Format(Date, "yyyy/mm/dd"), _
Type:=2)
If vResponse = False Then Exit Sub 'User cancelled
Loop Until IsDate(vResponse)
With Range("B2")
.NumberFormat = "mmm.dd.yyyy"
.Value = CDate(vResponse)
End With
ActiveSheet.Protect 'place at the end of the code
End Sub
****************************************************
Thanks! D