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
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
L

Legacy 98055

Guest
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,232
Messages
5,594,956
Members
413,954
Latest member
mrsandy

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
Top