ループ処理で最終行と最終列に合計を表示する
Sub 合計を求める()
Dim my_array As Variant
Dim s_row, s_col As Long
Dim max_row, max_col As Long
s_row = 1
s_col = 1
max_row = Cells(Rows.Count, s_col).End(xlUp).Row
max_col = Cells(s_row, Columns.Count).End(xlToLeft).Column
my_array = Range(Cells(s_row, s_col), Cells(max_row, max_col))
For i = s_row To max_row
Cells(i, max_col + 1).Formula = _
"=SUM(A" & i & ":" & _
Cells(i, max_col).Address(False, False) & ")"
Next i
MsgBox "完了 "
End Sub
コメント