主题
Errors (对象)
说明
使用 Range 对象的 Errors 属性可返回 Errors 对象。
返回 Errors 对象后,可使用 Error 对象的 Value 属性检查特定的错误检查条件。
python
#下例将一个数字作为文本放在单元格 A1 中,然后当单元格 A1 的值包含文本格式的数字时通知用户
def test():
#Place a number written as text in cell A1.
Range("A1").Formula = "'1"
if Range("A1").Errors.Item(xlNumberAsText).Value == True:
print("Cell A1 has a number as text.")
else:
print("Cell A1 is a number.")