ExcelBanter

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

Rafi

InputBox Cancel event
 
I have the following code prompting the user to select a range.

Set rng = Application.InputBox(Msg1, Title1, Type:=8)

I need to be able to trap both a CANCEL event as well as when the user
clicks "OK" without selecting a range.

Chip Pearson

InputBox Cancel event
 

Try something like

Dim R As Range
On Error Resume Next
Set R = Application.InputBox(prompt:="Enter", Type:=8)
If R Is Nothing Then
Debug.Print "cancelled"
Else
Debug.Print "selected: " & R.Address
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Mon, 9 Feb 2009 07:12:01 -0800, Rafi
wrote:

I have the following code prompting the user to select a range.

Set rng = Application.InputBox(Msg1, Title1, Type:=8)

I need to be able to trap both a CANCEL event as well as when the user
clicks "OK" without selecting a range.



All times are GMT +1. The time now is 02:01 PM.

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