我设计了一个代码,使用if else语句将两列相乘但我在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
答案 0 :(得分:3)
i
在第L = Cells(i, "L").Value
行进行了单元化,因此其值为0.单元格数组基于1。