Excel VBA - 检测无效引用的函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9970387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 15:42:54  来源:igfitidea点击:

Excel VBA - Function to Detect Invalid Reference

excelexcel-vbakeyboard-shortcutsvba

提问by Steveng

I am new to excel vba. Is there any function that would detect the cell value as #REF!?

我是 excel vba 的新手。是否有任何函数可以将单元格值检测为#REF!

回答by chris neilsen

Assuming CellReferencereferences a cell,

假设CellReference引用一个单元格,

To detect anyerror, use If IsError(CellReference) Then

要检测任何错误,请使用If IsError(CellReference) Then

To detect #REF!specifically use If CellReference = CVErr(xlErrRef) Then

检测#REF!具体使用If CellReference = CVErr(xlErrRef) Then