A1 B1 C1 D1 E1
67078S SHORT A01 L 1
67078S SHORT A01 L 2
67078S SHORT A01 L 3
67077S SHORT A01 M 1
67077S SHORT A01 M 2
67077S SHORT A01 S 3
67076S SHORT A01 XS 4
67076S SHORT A01 XS 4
67075S SHORT A01 XXS 5
エクセルで簡単に下記のようなデータのように
E1の数値を合算させる方法はあるのでしょうか?
A1 B1 C1 D1 E1
67078S SHORT A01 L 5
67077S SHORT A01 M 3
67077S SHORT A01 S 3
67076S SHORT A01 XS 8
67075S SHORT A01 XXS 5
集計を使えばいいようだけど、集計を使いたくなければマクロで。
A1,B1というのが1行目のセル(データは2行目から)と考えて、以下のマクロを実行。
ただし、前の表を上書きするので、実行する前に保存とかして戻せるようにしてください。
Sub Macro() Dim i As Long Dim j As Long Dim count As Long Dim flg As Boolean count = 2 i = 3 While Cells(i, 4).Value <> "" flg = True For j = 2 To count If Cells(i, 4).Value = Cells(j, 4).Value Then Cells(j, 5).Value = Cells(j, 5).Value + Cells(i, 5).Value flg = False Exit For End If Next j If flg Then count = count + 1 Cells(count, 1).Value = Cells(i, 1).Value Cells(count, 2).Value = Cells(i, 2).Value Cells(count, 3).Value = Cells(i, 3).Value Cells(count, 4).Value = Cells(i, 4).Value Cells(count, 5).Value = Cells(i, 5).Value End If If i <> count Then Cells(i, 1).Value = "" Cells(i, 2).Value = "" Cells(i, 3).Value = "" Cells(i, 4).Value = "" Cells(i, 5).Value = "" End If i = i + 1 Wend End Sub
回答者 | 回答 | 受取 | ベストアンサー | 回答時間 | |
---|---|---|---|---|---|
1 | kawasakisan | 31回 | 28回 | 0回 | 2007-04-18 13:07:33 |
コメント(0件)