Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default subtotal question

is there any easier way to use the subtotal property to get the count and
the sum of each group? it seems to only allow one or the other.
..Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(8)

so i adapted some code from the find help file to do this, but was wondering
if there was a better way.


Sub AddCount()
Dim cell As Range
Dim firstaddress As String
Dim c As Range
Dim lastrow As Long
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "B").End(xlUp).Row
With Worksheets("sheet1").Range("i4:i" & lastrow)
Set c = .Find("subtotal", LookIn:=xlFormulas)
If Not c Is Nothing Then
firstaddress = c.Address

Do
c.Offset(0, -4).Formula = Left(c.Formula, 10) & "3," _
& Right(c.Formula, Len(c.Formula) - 12)
c.Font.Bold = True
c.Offset(0, -4).Font.Bold = True
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstaddress
End If
End With

End Sub

--


Gary



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
Subtotal question [email protected] Excel Worksheet Functions 4 August 14th 08 12:05 AM
subtotal question? wonderdogs828 Excel Worksheet Functions 2 January 3rd 06 11:08 PM
subtotal question wonderdogs828 Excel Discussion (Misc queries) 1 January 3rd 06 10:13 PM
subtotal question hans[_4_] Excel Programming 1 April 6th 05 12:25 PM
Subtotal question Patricia Excel Worksheet Functions 2 November 23rd 04 07:25 PM


All times are GMT +1. The time now is 07:16 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"