VBA Excel单元格值"不"为NULL

Twi*_*Twi 2 excel vba excel-vba

我在for循环中获取单元格值,如下所示:

cellValue = rng.Cells(i, j).Value
Run Code Online (Sandbox Code Playgroud)

然后我检查单元格的值,如果它是空的我需要skipp,就像那样:

    If (Not IsEmpty(cellValue)) 
       /doThings/
Run Code Online (Sandbox Code Playgroud)

即使单元格值为空,IsEmpty(cellValue)条件也会变为空.我加了一块手表,看看这些牢房里面是什么,但我什么都没得到:

空单元格

在这些单元格中,我有一个公式,如果某些条件不为真,则返回"",这就是为什么单元格变空.

Sid*_*out 9

检查单元格是否为空的最佳方法是使用此方法

If Len(Trim(cellValue)) <> 0 Then
Run Code Online (Sandbox Code Playgroud)