```
Sub getTotals()
'Assumes data is in A:B (no header row)
Range("A1:B1").Insert -4121
Range("A1").Value = "Category"
Range("B1").Value = "Value"
Range("A1:B" & Range("B:B").Find("*", , , , , 2).Row).Copy Range("D1")
With Range("D1:E" & Range("D:D").Find("*", , , , , 2).Row)
.Sort Range("D2"), 1, , , , , , 1, , 0
.Subtotal 1, -4157, Array(2)
End With
With Range("D1:E" & Range("D:D").Find("*", , , , , 2).Row)
.Copy
.PasteSpecial -4163
.AutoFilter 1, "=*Total*", 1, "<>Grand Total"
End With
Range("D:E").SpecialCells(2).Copy Range("G1")
ActiveSheet.AutoFilterMode = 0
Range("D:E").RemoveSubtotal
Range("A1:I1").Delete -4162
Range("D:E").Delete
Range("G1:G" & Range("G:G").Find("*", , , , , 2).Row).FormulaR1C1 = "=COUNTIF(C[-6],LEFT(RC[-2],FIND("" "",RC[-2])-1))"
Columns("E:F").Columns.AutoFit
End Sub
```