Excel 2007 | |||||
---|---|---|---|---|---|
A | B | I | |||
1 | Item Type | Totals | |||
2 | 10096 | 9 | |||
3 | 10366 | 20 | |||
4 | 10366 | 29 | |||
5 | 10366 | 23 | |||
6 | 10370 | 20 | |||
7 | 10370 | 5 | |||
8 | 10370 | 13 | |||
9 | 10370 | 80 | |||
10 | 10370 | 10 | |||
11 | 10370 | 11 | |||
12 | 10370 | 29 | |||
13 | 10385 | 20 | |||
14 | |||||
15 | |||||
16 | |||||
17 | |||||
18 | |||||
Sheet1 |
Excel 2007 | |||||
---|---|---|---|---|---|
A | B | I | |||
1 | Item Type | Totals | |||
2 | 10096 | 9 | |||
3 | 9 | ||||
4 | 10366 | 20 | |||
5 | 10366 | 29 | |||
6 | 10366 | 23 | |||
7 | 72 | ||||
8 | 10370 | 20 | |||
9 | 10370 | 5 | |||
10 | 10370 | 13 | |||
11 | 10370 | 80 | |||
12 | 10370 | 10 | |||
13 | 10370 | 11 | |||
14 | 10370 | 29 | |||
15 | 168 | ||||
16 | 10385 | 20 | |||
17 | 20 | ||||
18 | |||||
Sheet1 |
Sub AutoSumItemType()
' hiker95, 07/08/2015, ME866881
Dim w1 As Worksheet
Dim r As Long, lr As Long
Dim Area As Range, sr As Long, er As Long
Application.ScreenUpdating = False
Set w1 = Sheets("Sheet1") '<-- you can change the sheet name here
With w1
lr = .Cells(Rows.Count, 1).End(xlUp).Row
For r = lr To 3 Step -1
If .Cells(r, 1) <> .Cells(r - 1, 1) Then
.Rows(r).Insert
End If
Next r
lr = .Cells(Rows.Count, 1).End(xlUp).Row
For Each Area In .Range("A2:A" & lr).SpecialCells(xlCellTypeConstants).Areas
With Area
sr = .Row
er = sr + .Rows.Count - 1
With w1.Range("I" & er + 1)
.Value = Evaluate("=Sum(B" & sr & ":B" & er & ")")
.Font.Bold = True
End With
End With
Next Area
End With
Application.ScreenUpdating = True
End Sub
Excel 2007 | ||||
---|---|---|---|---|
A | I | |||
6 | ||||
7 | 004Q9C | 1000 | ||
8 | 004R1C | 1000 | ||
9 | 004R1C | 2000 | ||
10 | 004R1C | 2000 | ||
11 | 004R1C | 2000 | ||
12 | 004R1C | 2000 | ||
13 | 005G3C | 2000 | ||
14 | 005G3C | 2000 | ||
15 | 008G9C | 2000 | ||
16 | ||||
17 | ||||
18 | ||||
19 | ||||
20 | ||||
Sheet1 |
Excel 2007 | ||||
---|---|---|---|---|
A | I | |||
6 | ||||
7 | 004Q9C | 1000 | ||
8 | 1000 | |||
9 | 004R1C | 1000 | ||
10 | 004R1C | 2000 | ||
11 | 004R1C | 2000 | ||
12 | 004R1C | 2000 | ||
13 | 004R1C | 2000 | ||
14 | 9000 | |||
15 | 005G3C | 2000 | ||
16 | 005G3C | 2000 | ||
17 | 4000 | |||
18 | 008G9C | 2000 | ||
19 | 2000 | |||
20 | ||||
Sheet1 |
Sub AutoSumItemType_V2()
' hiker95, 07/09/2015, ME866881
Dim w1 As Worksheet
Dim r As Long, lr As Long
Dim Area As Range, sr As Long, er As Long
Application.ScreenUpdating = False
Set w1 = Sheets("Sheet1") '<-- you can change the sheet name here
With w1
lr = .Cells(Rows.Count, 1).End(xlUp).Row
For r = lr To 8 Step -1
If .Cells(r, 1) <> .Cells(r - 1, 1) Then
.Rows(r).Insert
End If
Next r
lr = .Cells(Rows.Count, 1).End(xlUp).Row
For Each Area In .Range("A7:A" & lr).SpecialCells(xlCellTypeConstants).Areas
With Area
sr = .Row
er = sr + .Rows.Count - 1
With w1.Range("I" & er + 1)
.Value = Evaluate("=Sum(I" & sr & ":I" & er & ")")
.Font.Bold = True
End With
End With
Next Area
End With
Application.ScreenUpdating = True
End Sub