ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   InputBox Cancel Button (https://www.excelbanter.com/excel-programming/412905-inputbox-cancel-button.html)

A Mad Doberman

InputBox Cancel Button
 
How do I trap a CANCEL without explicitly using a variable? I am using
some code to have the user select a cell with the mouse in conjunction
with the InputBox function and want to exit the sub if the user hits
cancel.

Here is the relevant code.

Set Location = Application.InputBox(Prompt:= _
"Using your mouse, select a payee to delete.",
Title:="SELECT PAYEE TO DELETE", Type:=8)
PayeeAddress =
Location.Address
Range(PayeeAddress).Select
ActiveCell.EntireRow.Delete Shift:=xlUp

Thanks guys!

Bob Phillips[_3_]

InputBox Cancel Button
 
Dim Location As Range
On Error Resume Next
Set Location = Application.InputBox(Prompt:= _
"Using your mouse, select a payee to delete.", _
Title:="SELECT PAYEE TO DELETE", Type:=8)
On Error GoTo 0
If Not Location Is Nothing Then
....
End If


--
__________________________________
HTH

Bob

"A Mad Doberman" wrote in message
...
How do I trap a CANCEL without explicitly using a variable? I am using
some code to have the user select a cell with the mouse in conjunction
with the InputBox function and want to exit the sub if the user hits
cancel.

Here is the relevant code.

Set Location = Application.InputBox(Prompt:= _
"Using your mouse, select a payee to delete.",
Title:="SELECT PAYEE TO DELETE", Type:=8)
PayeeAddress =
Location.Address
Range(PayeeAddress).Select
ActiveCell.EntireRow.Delete Shift:=xlUp

Thanks guys!





All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com