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

Set myRange = Application.InputBox(prompt := "Sample",
type := 8)
I'm using VBA to have someone chose a cell range in an
excel program. The above statement was provided in the VBA
help menu under "input box". The input box works just fine
when you pick a cell and press OK. However this input box
also has a cancel button which returns "FALSE". As such
when you press CANCEL, the "Set" portion is looking for a
range input and it gets FALSE and gives a "type mismatch
error." Any way of fixing this??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Input Box Cancel Button

Try something like the following:

Dim MyRange As Range
On Error Resume Next
Set MyRange = Application.InputBox(prompt:="Test", Type:=8)
If MyRange Is Nothing Then
' user didn't select a range
Else
' user selected a range
End If


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




"rickylee" wrote in message
...
Set myRange = Application.InputBox(prompt := "Sample",
type := 8)
I'm using VBA to have someone chose a cell range in an
excel program. The above statement was provided in the VBA
help menu under "input box". The input box works just fine
when you pick a cell and press OK. However this input box
also has a cancel button which returns "FALSE". As such
when you press CANCEL, the "Set" portion is looking for a
range input and it gets FALSE and gives a "type mismatch
error." Any way of fixing this??



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Input Box Cancel Button

Thank You Very Much! The "On Error Resume Next" plus
the "IF" statement did the trick.

RLE
-----Original Message-----
Try something like the following:

Dim MyRange As Range
On Error Resume Next
Set MyRange = Application.InputBox(prompt:="Test",

Type:=8)
If MyRange Is Nothing Then
' user didn't select a range
Else
' user selected a range
End If


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




"rickylee" wrote in

message
...
Set myRange = Application.InputBox(prompt := "Sample",
type := 8)
I'm using VBA to have someone chose a cell range in an
excel program. The above statement was provided in the

VBA
help menu under "input box". The input box works just

fine
when you pick a cell and press OK. However this input

box
also has a cancel button which returns "FALSE". As such
when you press CANCEL, the "Set" portion is looking for

a
range input and it gets FALSE and gives a "type mismatch
error." Any way of fixing this??



.

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
Input Box Cancel Jase Excel Discussion (Misc queries) 2 September 15th 08 11:42 PM
Input Box - CANCEL Danny Excel Worksheet Functions 6 December 1st 06 02:15 AM
cancel input ME @ Home Excel Discussion (Misc queries) 1 February 22nd 06 09:49 AM
Clicking 'Cancel' on an Input box Big Chris[_18_] Excel Programming 4 November 28th 03 10:26 AM
input box cancel button Ian Mangelsdorf Excel Programming 1 August 28th 03 09:05 PM


All times are GMT +1. The time now is 07:20 PM.

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"