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 currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,539
Messages
5,832,327
Members
430,128
Latest member
ojl987

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