在循环中运行时间错误1004用于列乘法
我已经devise了一个代码来使用if else语句来乘两列,但是在L = Cells(i, "L").Value
上我得到了一个error 1004
L = Cells(i, "L").Value
因此我需要澄清一下为什么会发生这种情况。 这是代码!
Sub IfCalculationEq1() Dim lastrow As Long Application.ScreenUpdating = False Dim i As Long Dim L As Long Dim E As Long lastrow = Cells(Rows.Count, "L").End(xlUp).Row L = Cells(i, "L").Value E = Cells(i, "E").Value For i = 3 To lastrow If Cells(i, "K").Value = "-" Then Cells(i, "N").Value = "-" Else Cells(i, "N").Formula = "=L*E" Application.ScreenUpdating = True ' If k is null then no action required or else L1*E3 End If Next End Sub
i
在L = Cells(i, "L").Value
是单元化的,所以它的值为0.单元格数组为1。