![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
|
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?
__________________
Thanks in advance, Patrick |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
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 ? |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
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. |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|