|
▼マエ/ケン さん:
シートレイアウトで誤解しているところがあるかもしれませんが一例です。
Sub Sample()
Dim v As Variant
Dim w() As Long
Dim wk1 As Long, wk2 As Long
Dim tot1 As Long, tot2 As Long
Dim i As Long, x As Long
With Sheets("Sheet1") '<== 実際のシート名に
x = .Range("A" & .Rows.Count).End(xlUp).Row
v = .Range("A5").Resize(x - 4, 7).Value
ReDim w(LBound(v, 1) To UBound(v, 1))
For i = LBound(v, 1) To UBound(v, 1)
wk1 = v(i, 3) * v(i, 5)
wk2 = v(i, 3) * v(i, 6)
w(i) = wk1 + wk2
tot1 = tot1 + wk1
tot2 = tot2 + wk2
Next
.Range("H4").Value = "Total"
.Cells(x + 1, 1).Value = "合計"
.Cells(x + 1, 5).Value = tot1
.Cells(x + 1, 6).Value = tot2
.Range("H5").Resize(UBound(w)).Value = WorksheetFunction.Transpose(w)
End With
End Sub
|
|