VBAのヘルプが必要です。私はこのシートを持っています:
Game Room City Machines_week_1 Played_week_1 Won_week_1 Machines_week_2 Played_week_2 Won_week_2
A Julia San Francisco 3 1200 1100 2 500 250
B Julia San Francisco 4 200 100 1 500 250
C Julia San Francisco 3 500 100 5 600 250
D Julia San Francisco 1 200 50 2 1000 750
B Carla San Francisco 1 1000 600 2 1500 500
C Carla San Francisco 3 800 400 3 500 250
E Carla San Francisco 6 1200 1100 4 600 300
A Jaime Rio de Janeiro 1 200 50 2 90 50
C Jaime Rio de Janeiro 3 900 600 3 500 250
(....)
そして、シートの最後にある週ごとに、部屋を無視して、都市とゲームごとの合計を計算したいと思います。何かのようなもの:
Game Room City Machines_week_1 Played_week_1 Won_week_1 Machines_week_2 Played_week_2 Won_week_2
(...)
A Total San Francisco 3 1200 1100 2 500 250
B Total San Francisco 5 1200 700 3 3000 750
C Total San Francisco 6 1300 500 8 1100 500
D Total San Francisco 1 200 50 2 1000 750
E Total San Francisco 6 1200 1100 4 600 300
A Total Rio de Janeiro 1 200 50 2 90 50
C Total Rio de Janeiro 3 900 600 3 500 250
(....)
私は次のようなことを試みています:
For p = 1 To LastRow
If Range("CA1").Offset(i, 0).Value <> 2 Then ( I have this much of columns with data and weeks)
a = Range("A1").Offset(p, 0).Value
c = Range("C1").Offset(p, 0).Value
For i = 1 To LastRow
If Range("A1").Offset(i, 0).Value = a And Range("C1").Offset(i, 0).Value = c Then
Machines1 = Range("D1").Offset(i, 0).Value + Machines1
Played1 = Range("E1").Offset(i, 0).Value + Played1
(....)
Machines2 = Range("G1").Offset(i, 0).Value + Machines2
Played2 = Range("H1").Offset(i, 0).Value + Played2
Range("CA1").Offset(i, 0).Value = 2 (this column is empty, Im using it for a test to see if I have calculated this combination of city and game already)
End If
Next i
lastn = Range("A65536").End(xlUp).Row
Range("A1").Offset(lastn, 0).Value = a
Range("B1").Offset(lastn, 0).Value = "Total"
Range("C1").Offset(lastn, 0).Value = c
Range("D1").Offset(lastn, 0).Value = Machines1
Range("E1").Offset(lastn, 0).Value = Played1
(...)
Range("G1").Offset(lastn, 0).Value = Machines2
Range("H1").Offset(lastn, 0).Value = Played2
(...)
Machines1=0
Played1=0
Machines2=0
Played2 = 0
(....)
End If
Next p
しかし、それは機能していません。それはまだ部屋ごとにゲームを繰り返しています (合計は正しいですが、街にある部屋の数だけ表示されます)。誰かが私を助けることができれば、私はとても感謝しています。ありがとうございました!