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?? |
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?? |
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?? . |
All times are GMT +1. The time now is 10:43 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com