Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 奇怪的情况是,细胞似乎是空的,但不是空的_Vba_Excel - Fatal编程技术网

Vba 奇怪的情况是,细胞似乎是空的,但不是空的

Vba 奇怪的情况是,细胞似乎是空的,但不是空的,vba,excel,Vba,Excel,我的工作表中有一些假定为空的单元格,这给我带来了麻烦 在运行任何代码之前,任何单元格的IsNull和IsEmpty函数的输出都为False 但是,以下代码对于任何单元格都能令人惊讶地工作,即使它正在查找空单元格: If cell.value = "" Then cell.value = "Unassigned" 更奇怪的是,如果我尝试反转此代码: If cell.value = "Unassigned" Then cell.value = "" ,单元格上IsNull的输出仍将为False

我的工作表中有一些假定为空的单元格,这给我带来了麻烦

在运行任何代码之前,任何单元格的IsNull和IsEmpty函数的输出都为False

但是,以下代码对于任何单元格都能令人惊讶地工作,即使它正在查找空单元格:

If cell.value = "" Then cell.value = "Unassigned" 
更奇怪的是,如果我尝试反转此代码:

If cell.value = "Unassigned" Then cell.value = ""
,单元格上IsNull的输出仍将为False,但IsEmpty将变为True

这在更大的范围内给我带来了很多麻烦,因为我使用数据透视表来汇总数据,包括那些麻烦的单元格,在运行这两行代码之前,数据透视不会为这些空白单元格分配任何标签,但在运行代码之后,它将使用空白标签。我需要命名保持一致

考虑一下:

Debug.Print IsNull("X")
False
Debug.Print IsNull("")
False
Debug.Print IsNull(Empty)
False
Debug.Print IsNull(Null)
True
IsNull将仅为Null返回true。它不适用于单元值测试。

考虑以下情况:

Debug.Print IsNull("X")
False
Debug.Print IsNull("")
False
Debug.Print IsNull(Empty)
False
Debug.Print IsNull(Null)
True
IsNull将仅为Null返回true。它不适用于单元格值测试。

可能重复的可能重复的