input box help

Chavira55

Board Regular
Joined
Sep 19, 2002
Messages
65
my workbook works fine, until someone decides to skip answering the nessesary questions off of the boxes,HOW Can I put a critical box if they enter a wrong value or if no data is entered? this is what I have
Sub GetDate()
Dim Message As String, Title As String
Dim Default As String, Myvalue As String

Message = "Please enter next Schedule Date (EXAMPLE xx/xx/xx)"

' Set prompt.
Title = "Date input"
' Set title.
Default = "Enter Date Here!"
' Set default.
' Display message, title, and default value.
Myvalue = InputBox(Message, Title, Default)

Range("D3").Select
ActiveSheet.Unprotect
ThisWorkbook.Sheets("SCHEDULE").Range("D3").Value = Myvalue
Range("D3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("M7").Select
End Sub
any help is apreciated
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi
I edited your procedure to check for a valid date. If an invalid date was entered, a messagebox will notify the user of their error and show the input box until they get it right...
<pre>
Sub GetDate()
Dim Message As String, Title As String
Dim Default As String, Myvalue As String

ShowDialog:

Message = "Please enter next Schedule Date (EXAMPLE xx/xx/xx)"

' Set prompt.
Title = "Date input"
' Set title.
Default = "Enter Date Here!"
' Set default.
' Display message, title, and default value.
Myvalue = InputBox(Message, Title, Default)

If Not IsDate(Myvalue) Then
MsgBox "You entered an invalid date." & Chr(13) & _
"Please re-enter a date.", vbSystemModal, "Error Entry"
GoTo ShowDialog
End If

Range("D3").Select
ActiveSheet.Unprotect
ThisWorkbook.Sheets("SCHEDULE").Range("D3").Value = Myvalue
Range("D3").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("M7").Select
End Sub

</pre>
Tom
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top