2016-07-25 72 views
0

我试图寻找与错误424的问题,但我没有找到任何符合我的情况。VBA错误424与空

我正在3号线一个424错误:

For icount = 2 To no_items 
    If hid.Cells(icount, 1).Value > 0 Then 
     'If hid.Cells(icount, 1).Offset(-1).Value Is Empty Then 
      'hid.Cells(icount, 1).Value = 1 
     'Else 
      hid.Cells(icount, 1).Value = 1 + hid.Cells(icount, 1).Value 
     'End If 
    End If 
Next 

我的声明如下:

Dim hid As Worksheet 
Set hid = ThisWorkbook.Worksheets("Hidden") 
hid.Visible = True 

之前,我曾与第2行相同的错误:

If hid.Cells(icount, 1) is not empty Then 

我不明白为什么会出现错误,一切都按照它应该的方式定义。 你能帮我吗?用于不为IsEmpty

+0

见下文 –

回答

1

你的语法是不正确的,你需要改变你的线路:

If hid.Cells(icount, 1) is not empty Then 

要:

If Not IsEmpty(hid.Cells(icount, 1)) Then 
+0

我的回答,我改变了空与值为0,它的工作原理。对于字符串是'空'函数吗?* –

+0

@AmandineFAURILLOU你的代码语法和你放置'Not IsEmpty'的地方是错误的。你也可以修改为'If hid.Cells(icount,1).Offset(-1).Value <>“”Then' –

+0

@AmandineFAURILLOU是否可以解答你的问题? –