Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Cancel button in Inputbox method

Hi everybody,
when I use Inputbox method with Type : = 8 (Set MyObject = Input....) and I
click on Cancel button, I will get an error.
Is there any way to avoid this without On Error Goto Label ?

Thanks for answer.

MiRa


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Cancel button in Inputbox method

MiRa,

Try something like the following:

Dim Rng As Range
On Error Resume Next
Set Rng = Application.InputBox("select", Type:=8)
On Error GoTo 0
If Rng Is Nothing Then
MsgBox "You clicked Cancel"
Else
MsgBox "You selected: " & Rng.Address
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"MiRa" wrote in message
...
Hi everybody,
when I use Inputbox method with Type : = 8 (Set MyObject = Input....) and

I
click on Cancel button, I will get an error.
Is there any way to avoid this without On Error Goto Label ?

Thanks for answer.

MiRa




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Cancel button in Inputbox method


Mira,

no, you'll have to prevent the error when the inputbox is cancelled.


Sub inputtest()
Dim rngVariable As Range
On Error Resume Next
Set rngVariable = Application.InputBox(prompt:="Range?", Type:=8)
On Error GoTo 0

If rngVariable Is Nothing Then
'user cancelled
Else
MsgBox rngVariable.Address
End If

End Sub

keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"MiRa" wrote:

Hi everybody,
when I use Inputbox method with Type : = 8 (Set MyObject = Input....)
and I click on Cancel button, I will get an error.
Is there any way to avoid this without On Error Goto Label ?

Thanks for answer.

MiRa




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
InputBox / VBA question ok = print, cancel = exit todd78 Excel Worksheet Functions 4 August 9th 07 04:42 PM
Detecting Cancel in an InputBox Method Connie Excel Discussion (Misc queries) 2 October 19th 06 01:32 PM
Inputbox method using type:=8 - How to Cancel? Joe 90 Excel Programming 0 July 10th 03 12:24 AM
Inputbox method using type:=8 - How to Cancel? Harlan Grove[_5_] Excel Programming 1 July 9th 03 12:06 AM
Inputbox method using type:=8 - How to Cancel? Jim Cone Excel Programming 0 July 8th 03 06:15 PM


All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"