Round subtotals to two decimal places

M

marcia2026

I have a macro that is in part from a recorded macro and part from on of
these posts. It doesn't quite do what it needs to. For some reason, some of
my subtotals need to be formulated as: =round(subtotal(9,A1:A2),2) in order
to get the formating correct. I use the accounting method so that zero
totals will be a dash instead of a 0. Can someone please tell me how to
alter my subtotal formula?
Code:
Sub Subtotals()

'Create subtotals
Range("A2").Select
Selection.Subtotal GroupBy:=3, Function:=xlSum, TotalList:=Array(6, 7),
Replace:=True, PageBreaks:=False, SummaryBelowData:=True


'Round off the subtotals so that zeros will be in accounting format

Dim myC As Range
For Each myC In Cells.SpecialCells(xlCellTypeFormulas, 23)
If InStr(1, myC.Formula, "SUBTOTAL") > 0 Then
myC.Font.Bold = True
myC.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* ""-""??_);_(@_)"

End If
Next myC
End Sub

thanks
marcia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Rounding Subtotals to 2 places 1
Subtotal Formatting 2
Issue with nested data subtotals 3
Excel Subtotals 2
List subtotals 0
Only Copy Subtotals 8
Subtotals problem - wierd! 0
Subtotal by VBA 5

Top