bugarin1010
Board Regular
- Joined
- Jan 28, 2008
- Messages
- 59
Hi,
I'm trying to force a user to input a date as "mm/yyyy" format only. I'm using a msgbox to capture the user response and if it passes, I go onto my next step. Otherwise, I want to have the user correct the date input format. I have the following code that I believe is almost there, but something isn't working quite right since it gets stuck in an endless loop. Here is the code:
Any help is greatly appreciated. Thanks in advance!!
I'm trying to force a user to input a date as "mm/yyyy" format only. I'm using a msgbox to capture the user response and if it passes, I go onto my next step. Otherwise, I want to have the user correct the date input format. I have the following code that I believe is almost there, but something isn't working quite right since it gets stuck in an endless loop. Here is the code:
Code:
Sub start_date()
Dim start_date As Integer
Dim UserEntry As String
Dim Msg As String
Dim TheDate As String
Msg = "Enter Date as mm/yyyy"
TheDate = Format(Date, "mm/yyyy")
Do
UserEntry = InputBox(Msg)
If UserEntry = "" Then Exit Sub
If UserEntry = TheDate Then
ActiveSheet.Range("B16").Value = UserEntry
Exit Sub
Else
Msg = "Please try again. Enter date as mm/yyyy"
End If
Loop
End Sub
Any help is greatly appreciated. Thanks in advance!!