Here is some code right out of one of my macros:
Dim SomeValue as Integer
Dim Answer as Integer
' Determine if value has been entered
SomeValue = InputBox("Enter a Value", 0)
If SomeValue = 0 Then
Beep
Answer = MsgBox("Value is missing! Do you wish to continue ?", vbYesNo + vbQuestion + vbDefaultButton2 + vbSystemModal)
If Answer = vbNo Then
Exit Sub
End If
End If
Other code
. . .
. . .
Hi,
Exit sub works for me. I think maybe ur criteria at the If statement might not be working.
What does ur IF statement test for?
Here is one of the statemetns directly copied/pasted,
Firstname = Application.InputBox("Please enter the first name to search for.", Type:=1)
If IsEmpty(Firstname) Then End
I also tried this,
Firstname = Application.InputBox("Please enter the first name to search for.", Type:=1)
If IsEmpty(Firstname) Then Exit Sub
and this,
Firstname = Application.InputBox("Please enter the first name to search for.", Type:=1)
If IsEmpty(Firstname) Then Exit Sub
End If
and this
Firstname = Application.InputBox("Please enter the first name to search for.", Type:=1)
If Firstname="" Then Exit Sub
Every time I hit cancel it will just jump to the next line. There are three parts to this macro, the two input boxes for first and last name, then the code to make a graph. If cancel is pressed on the first input box it jumps to the next box. If cancel is pressed on the second input box it jumps straight to the graph making part. Of course since no input was taken it makes a blank graph.
This seems like adding If...Then Exit Sub would work perfectly, but it isn't so far.
Am I missing something completely obvious?
Thanks again =)
Michael Robson
Hi,
Try this
firstname = Application.InputBox(Prompt:="Please enter the first name to search for.")
If (firstname) = False Then Exit Sub
Hi,
Try this
firstname = Application.InputBox(Prompt:="Please enter the first name to search for.")
If (firstname) = False Then Exit Sub
I guess inputbox returns a boolean
Tell me if it works for u
Thanks Jaime!
That did the trick! Although I still am not sure why it wasn't working before I can at least rest knowing it does now. =)
Thanks again,
Michael Robson Hi, Try this firstname = Application.InputBox(Prompt:="Please enter the first name to search for.") If (firstname) = False Then Exit Sub
Yeah, In fact i have a textbook that codes it just like u did. But it does not seem to work that way. Go figure, MS