2016-03-29 4 views
1

2つの列にif else文を掛けるコードを設計しましたが、error 1004L = Cells(i, "L").Valueに取得しています。なぜこれが起こっているのかを明確にする必要があります。 これはコードです!実行時エラー1004列での乗算のループ

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 

答えて

3

iL = Cells(i, "L").Valueでunititializedので、セルアレイが1基づいて0の値を有しています。

+0

ありがとうございました!私はそれを実行し、ExcelがL * E関数を認識しないためにおそらく動作しないことに気付きました。それについてどうすればいいですか? – Niva

+1

@Niva - あなたが構築しようとしている式が何であるか正確にはわかりませんが、私はそれが 'Cells(i、" N ")のようなものでなければならないと推測しています。 "&i' – Comintern

関連する問題