INput box help


Posted by Fred Wilson on March 22, 2001 8:48 AM

I have a input box. I need to cancel the cancel button. Everything that I have tried overides most of mt other code. WHat can I do.

Posted by Ivan Moala on March 22, 2001 5:21 PM

Have a look @ this example and adapt to
your macro;
The key here is the False value returned.

Sub Namesheet()
Dim EmployeeName As String

again:
EmployeeName = Application.InputBox("Please enter your name", "New Employee")
If EmployeeName = "False" Then GoTo again

Sheets.Add
On Error Resume Next
ActiveSheet.Name = EmployeeName
If Err <> 0 Then
Application.DisplayAlerts = False
ActiveSheet.Delete
GoTo again
End If
On Error GoTo 0
End Sub




Posted by Dave Hawley on March 22, 2001 10:42 PM

Hi Fred

The Cancel button returns an empty string, so this code will not allow a user to Cancel:

Sub TryThis()
Dim Reply As String
Reply = InputBox("How old are you ?", "Age Box")
If Reply = "" Then TryThis
End Sub


OzGrid Business Applications