Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default InputBox Cancel event

How do I trap a Cancel event on the following code? I have tried the most
common IF statements however, the code blows up before getting to the IF
statement when CANCEL is clicked.

Set rng = Application.InputBox(Msg1, Title1, Type:=8)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default InputBox Cancel event

hi
if the user clicks cancel, the input box returns a zero length string.
something like this might work.....
if return = "" then
msgbox "nothing entered?!?!"
exit sub '??
end if

play with it.
regards
FSt1
"Rafi" wrote:

How do I trap a Cancel event on the following code? I have tried the most
common IF statements however, the code blows up before getting to the IF
statement when CANCEL is clicked.

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default InputBox Cancel event

Try

Dim rng As Range
On Error Resume Next
Set rng = Application.InputBox(Prompt:=msg1, Title:=title1, Type:=8)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "User Cancelled"
Exit Sub
End If
' Do lots of things

Mike

"Rafi" wrote:

How do I trap a Cancel event on the following code? I have tried the most
common IF statements however, the code blows up before getting to the IF
statement when CANCEL is clicked.

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

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 Cancel event Rafi Excel Programming 1 February 9th 09 03:30 PM
InputBox Cancel Button A Mad Doberman Excel Programming 1 June 20th 08 09:49 PM
InputBox: Separate CANCEL and 0 Mike Excel Programming 3 July 20th 07 03:14 PM
InputBox - cancel button Greg Billinge Excel Programming 4 October 11th 04 06:45 PM
Inputbox and cancel button Uddinj1 Excel Programming 5 March 2nd 04 11:27 AM


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

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

About Us

"It's about Microsoft Excel"