Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Round subtotals to two decimal places
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 marcia |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i round a quotient to specific decimal places? | Excel Worksheet Functions | |||
Subtracting two 2-decimal place numbers gives result 13-decimal places? | Excel Worksheet Functions | |||
Round variable to 4 decimal places | Excel Programming | |||
FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT. | Excel Discussion (Misc queries) | |||
ROUND DATA TO 2 DECIMAL PLACES | New Users to Excel |