小编Jer*_*ton的帖子

处理InputBox的取消以选择范围

我有以下代码:

dim selectRange as Range
Set selectRange = Application.InputBox("Select your range", "Hello", , , , , , 8)
Run Code Online (Sandbox Code Playgroud)

当用户选择取消InputBox提示时,它将返回error of Object not set.

我试图使用Variant变量类型但我无法处理它.在取消的情况下,它返回False,同时在选择范围的情况下,它返回InputBox的范围.

我怎样才能避免这个错误?

error-handling excel vba excel-vba inputbox

8
推荐指数
3
解决办法
2万
查看次数

标签 统计

error-handling ×1

excel ×1

excel-vba ×1

inputbox ×1

vba ×1