Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Rounding Subtotals to 2 places

I have a small macro that is in part from a recorded macro and in part a
small macro that I found on a post here, but it doesn't quite do what I want.
Sometimes my subtotals need to be rounded to 2 places in order to get the
accounting format. I have been doing this by hand, but with some 100 tax
types with total for both current period and year to date it is a chore.

If someone could help me to correct this I would appreciate it.

[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
[/Code}

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Rounding Subtotals to 2 places

On Feb 16, 5:27*pm, marcia2026
wrote:
I have a small macro that is in part from a recorded macro and in part a
small macro that I found on a post here, but it doesn't quite do what I want.
*Sometimes my subtotals need to be rounded to 2 places in order to get the
accounting format. *I have been doing this by hand, but with some 100 tax
types with total for both current period and year to date it is a chore.

If someone could help me to correct this I would appreciate it. *

[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
[/Code}



I got this from the macro recorder -

myC.Style = "Comma"
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
rounding decimal places Cherie QLD Excel Discussion (Misc queries) 4 September 10th 08 05:24 AM
Set fixed Decimal places with no rounding azza Excel Worksheet Functions 4 July 4th 08 04:48 AM
Rounding to two even decimal places needhelp Excel Worksheet Functions 3 May 16th 07 12:49 AM
Rounding off decimal places Clay64 Excel Discussion (Misc queries) 7 March 29th 07 10:30 PM
Decimal places and rounding up (or down) Ash New Users to Excel 3 February 15th 05 08:16 PM


All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"