ループのなか特定セルに数式を入れる

 

Sub test()

    ' ループのなか特定セルに数字を入れる

 

    Dim i As Long
    Dim myMaxR As Long
    
    With Sheets(1)
  
            myMaxR = .Cells(.Rows.Count, "A").End(xlUp).Row  '最終行

            For i = 2 To myMaxR

       ’ B列が数字のときのみ下記数式を入れる
                If IsNumeric(.Cells(i, "B")) Then
                        .Range("F" & i).FormulaR1C1 = "=Round(RC[-3]*RC[-4],0)"     
                End If
            Next i

    End With

End Sub

 

 

 

 

 

実行結果

 

 

― ― ― ― ― ― ― ― ― ― → Excel VBA基礎入門もくじ へ戻る 

 

参考記事