ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   application.inputbox (https://www.excelbanter.com/excel-programming/292366-application-inputbox.html)

Murat

application.inputbox
 
Hi,

When i run following program and press Cancel button, Error Code: 424
occurs.

Dim aralik As Range
Set aralik = Application.InputBox(prompt:="Select range:", Type:=8)

How can i check that the cancel button was pressed?



papou[_7_]

application.inputbox
 
Hello Murat
Dim aralik As Range
On Error Resume Next
Set aralik = Application.InputBox(prompt:="Select range:", Type:=8)
If Err Then
MsgBox "You pressed cancel"
End If

HTH
Regards
Pascal

"Murat" a écrit dans le message de
...
Hi,

When i run following program and press Cancel button, Error Code: 424
occurs.

Dim aralik As Range
Set aralik = Application.InputBox(prompt:="Select range:", Type:=8)

How can i check that the cancel button was pressed?





Frank Kabel

application.inputbox
 
Hi
try

Sub foo()
....
Dim aralik As Range
On Error Resume Next
Set aralik = Application.InputBox(prompt:="Select range:", Type:=8)
If Err < 0 Then
Exit Sub
End If
On Error GoTo 0
' your code
....
End Sub




--
Regards
Frank Kabel
Frankfurt, Germany

Murat wrote:
Hi,

When i run following program and press Cancel button, Error Code: 424
occurs.

Dim aralik As Range
Set aralik = Application.InputBox(prompt:="Select range:", Type:=8)

How can i check that the cancel button was pressed?



Bob Phillips[_6_]

application.inputbox
 
Murat,

The problem is being caused by the Set statement, there is nothing to set
when Cancel is hit. In this sort of instance, you have to manage the
situation yourself, trap the error and respond to that.

To trap the error, use On Error Resume Next. Check help for details.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Murat" wrote in message
...
Hi,

When i run following program and press Cancel button, Error Code: 424
occurs.

Dim aralik As Range
Set aralik = Application.InputBox(prompt:="Select range:", Type:=8)

How can i check that the cancel button was pressed?





Murat

application.inputbox
 
Thanks all


"Murat" wrote in message
...
Hi,

When i run following program and press Cancel button, Error Code: 424
occurs.

Dim aralik As Range
Set aralik = Application.InputBox(prompt:="Select range:", Type:=8)

How can i check that the cancel button was pressed?






All times are GMT +1. The time now is 06:29 AM.

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