运行VBA for循环时出现未知的神秘错误

我想使用下面的VBA子查找相应的第一列值为每个后续列的初始负值/最后正值,但是当我运行它立即给了我一个

“400”

错误。 你们知道有什么可能的原因吗?

Sub findzero() For i = 225 To 335 For j = 19 To 10018 If Range(Cells(j, i)).Value < 0 Then Range(Cells(14, i)).Value = Range(Cells(j - 1, 1)).Value Exit For End If Next j Next i End Sub 

当我运行这个,我得到一个不同的错误比你。 我得到了“_Global”对象的“方法范围”失败。 不过,我不太清楚为什么我们的信息是不同的。

无论如何,我不认为这是正确使用“范围”对象(对象?)。 它要么是Range(Cells(j,i),Cells(j,i)).Value (select一个只包含一个单元格的“范围”)或者只包含Cells(j,i).

 For i = 225 To 335 For j = 19 To 10018 If Cells(j, i) < 0 Then Cells(14, i) = Cells(j - 1, 1) Exit For End If Next j Next i 

或者,或者,

 For i = 225 To 335 For j = 19 To 10018 If Range(Cells(j, i), Cells(j, i)).Value < 0 Then Range(Cells(14, i), Cells(14, i)).Value = Range(Cells(j - 1, 1), Cells(j - 1, 1)).Value Beep Exit For End If Next j Next i 

我个人比较喜欢第一种方式。 可能有更好的方法来做到这一点,但我不知道它会是什么。