Hi,
Can Someone help me with the VBA? I have code but i dont know how to change to insert Text and then Total.
Sub Test()
Dim Rng As Range
Dim x As Long
Set Rng = Range("F1:F" & Range("F65536").End(xlUp).Row)
For x = Rng.Rows.Count To 2 Step -1
If Rng.Cells(x, 1).Offset(-1, 0).Value <> Rng.Cells(x, 1).Value Then
'insert Text "TOTAL"
Rng.Cells(x, 1).EntireRow.Insert Shift:=xlDown
'insert AutoSUM formula next to "TOTAL"
Rng.Cells(x, 1).EntireRow.Insert Shift:=xlDown
Rng.Cells(x, 1).EntireRow.Insert Shift:=xlDown
End If
Next x
End Sub
<TBODY>
</TBODY>
Can Someone help me with the VBA? I have code but i dont know how to change to insert Text and then Total.
Sub Test()
Dim Rng As Range
Dim x As Long
Set Rng = Range("F1:F" & Range("F65536").End(xlUp).Row)
For x = Rng.Rows.Count To 2 Step -1
If Rng.Cells(x, 1).Offset(-1, 0).Value <> Rng.Cells(x, 1).Value Then
'insert Text "TOTAL"
Rng.Cells(x, 1).EntireRow.Insert Shift:=xlDown
'insert AutoSUM formula next to "TOTAL"
Rng.Cells(x, 1).EntireRow.Insert Shift:=xlDown
Rng.Cells(x, 1).EntireRow.Insert Shift:=xlDown
End If
Next x
End Sub
Apple | 3 |
Apple | |
Apple | 4 |
Apple | |
Apple | |
Total | 7 |
Orange | |
Orange | 3 |
Orange | |
Orange | |
Total | 3 |
Cheese | 9 |
Cheese | |
Cheese | 3 |
Total | 12 |
<TBODY>
</TBODY>