2016-07-25 28 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是否可以解答你的問題? –