Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Input Box Cancel | Excel Discussion (Misc queries) | |||
Input Box - CANCEL | Excel Worksheet Functions | |||
cancel input | Excel Discussion (Misc queries) | |||
Clicking 'Cancel' on an Input box | Excel Programming | |||
input box cancel button | Excel Programming |