' 宣言していない変数を使用不可にする. Option Explicit Sub MainProc() Dim i As Integer, j As Integer Dim m As Integer, n As Integer m = 3 n = 5 For i = 1 To m For j = 1 To n ActiveSheet.Range("A1").Cells(j, i).Value = (j - 1) * m + i Next j Next i End Sub