InputBox

poleary2000

Active Member
Joined
Apr 1, 2002
Messages
354
I have the following code:

On Error GoTo Canceled
NewWONumber = InputBox("Enter the new work order number", "Work Order Number")
On Error GoTo Canceled
NewClient = InputBox("Enter the new client / description", "Description")
On Error GoTo Canceled
NewLocation = InputBox("Enter the new location", "Location")

How can I make it so if the user clicks Cancel on the InputBox, the sub is ended?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Sub T()
Dim ans As Variant

ans = InputBox("Testing", "Testing")

If ans = "" Then
MsgBox "Pressed Cancel, exiting now"
Exit Sub
Else
MsgBox ans
End If
End Sub


Something like this ?
 
Upvote 0
Hi Patrick
I'd also suggest looking at the Application
inputbox method, it gives you options to
limit the user input to formulas, numbers,
text, logical value (True or False), cell reference, as a Range object etc.
 
Upvote 0
On 2002-04-12 13:54, Ivan F Moala wrote:
Hi Patrick
I'd also suggest looking at the Application
inputbox method, it gives you options to
limit the user input to formulas, numbers,
text, logical value (True or False), cell reference, as a Range object etc.

Sticking to Ivan's advice, when the user presses Cancel, the Application.InputBox method returns False, instead of "" (Which I prefer !)
 
Upvote 0

Forum statistics

Threads
1,213,563
Messages
6,114,329
Members
448,564
Latest member
ED38

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