繰り返し
Sub rei1() Dim myCnt As Long For myCnt = 1 To 10 Cells(myCnt, 3).Value = Cells(myCnt, 1).Value * Cells(myCnt, 2).Value Next myCnt End Sub |
Sub rei1() Dim myCnt As Long For myCnt = 1 To 10 Step 2 Cells(myCnt, 3).Value = Cells(myCnt, 1).Value * Cells(myCnt, 2).Value Next myCnt End Sub |
Sub rei1() Dim myCnt As Long For myCnt = 1 To 10 If myCnt = 5 Then Exit For Cells(myCnt, 3).Value = Cells(myCnt, 1).Value * Cells(myCnt, 2).Value Next myCnt End Sub |
Sub rei_kuku1() Dim i As Integer Dim j As Integer For i = 1 To 9 For j = 1 To 9 Cells(i + 1, j + 1).Value = i * j Next j Next i End Sub |
Sub rei_kuku1() Dim i As Integer Dim j As Integer For i = 1 To 9 For j = 1 To 9 Range("A1").Offset(i, j).Value = i * j Next j Next i End Sub |
Sub rei_kuku1() Dim i As Integer Dim j As Integer For i = 1 To 9 For j = 1 To 9 Range("A1").Offset(i, j).Value = _ Range("A1").Offset(i, 0).Value * Range("A1").Offset(0, j).Value Next j Next i End Sub |
Sub rei1() Dim myRng As Range Dim c As Range Set myRng = Range("C1:C10") For Each c In myRng c.Value = c.Offset(0, -2).Value * c.Offset(0, -1).Value Next c End Sub |
Sub rei1() Dim myCnt As Long myCnt = 1 Do While myCnt <= 5 Cells(myCnt, 3).Value = Cells(myCnt, 1).Value * Cells(myCnt, 2).Value myCnt = myCnt + 1 Loop End Sub |
Sub rei1() Dim myCnt As Long myCnt = 1 Do Cells(myCnt, 3).Value = Cells(myCnt, 1).Value * Cells(myCnt, 2).Value myCnt = myCnt + 1 Loop While myCnt < 6 End Sub |
Sub rei1() Dim myCnt As Long myCnt = 1 Do Until myCnt > 5 Cells(myCnt, 3).Value = Cells(myCnt, 1).Value * Cells(myCnt, 2).Value myCnt = myCnt + 1 Loop End Sub |
Sub rei1() Dim myCnt As Long myCnt = 1 Do Cells(myCnt, 3).Value = Cells(myCnt, 1).Value * Cells(myCnt, 2).Value myCnt = myCnt + 1 If myCnt > 5 Then Exit Do Loop End Sub |