LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Help with Totalling Groups Please

Hi,

The Macro Below Produces a Total ( nType ) and Grand Total ( nTypeTotal
) Related to Variable i.
I would However, like to Add at the Bottom ( Starting 2 Rows Down from
the Already Produced Grand Total in the Macro ) the Totals for the
Following Groups :-

Total for 103 to 122 = 351,106
Total for 123 to 142 = 160,900
Total for 143 to 162 = 30,227
Total for 163 to 182 = 1,512
Total for 183 to 203 = 1
Grand Total = 543,746

Here is the Macro :-

Option Explicit
Option Base 1

Sub Test()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim E As Integer
Dim F As Integer
Dim i As Integer
Dim nType(203) As Long
Dim nTypeTotal As Long
Dim rng As Range

Application.ScreenUpdating = False
Sheets("Results").Select
Range("B3").Select

For i = 103 To 203
nType(i) = 0
Next i

For A = 1 To 33 - 5
For B = A + 1 To 33 - 4
For C = B + 1 To 33 - 3
For D = C + 1 To 33 - 2
For E = D + 1 To 33 - 1
For F = E + 1 To 33

nType(A + B + C + D + E + F) = nType(A + B + C + D + E + F) + 1

Next F
Next E
Next D
Next C
Next B
Next A

nTypeTotal = ActiveCell.Row

For i = 103 To 203
ActiveCell.Offset(1, 0).Value = "Total for"
ActiveCell.Offset(1, 1).Value = i
ActiveCell.Offset(1, 2).Value = nType(i)
ActiveCell.Offset(1, 0).Select
Next i

ActiveCell.Offset(1, 0).Value = "Grand Total"

Set rng = ActiveCell.Offset(1, 2)
rng.FormulaR1C1 = "=Sum(R" & nTypeTotal & "C:R[-1]C)"
rng.Formula = rng.Value

Application.ScreenUpdating = True
End Sub

I have Tried Adapting "=Sum(R" & nTypeTotal & "C:R[-1]C)" which Works (
Thanks to Tom Ogilvy & Bob Phillips ) for the Grand Total in the Macro
Above But to NO Avail.
Is this Possible Using Code like the nTypeTotal to Output the Values
Instead of the Code Entering Formulas into the Worksheet Please.

Any Help will be Greatly Appreciated.
Thanks in Advance.
All the Best.
Paul




*** Sent via Developersdex http://www.developersdex.com ***
 
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
Excel - Sorting groups in groups due to subtotaling [email protected] Excel Worksheet Functions 3 April 4th 08 06:13 PM
My SUM function is totalling to 0 Caroline Excel Worksheet Functions 0 January 19th 07 08:29 PM
Totalling volumes per box Brian Excel Worksheet Functions 5 December 6th 06 06:40 PM
totalling enyaw Excel Discussion (Misc queries) 1 May 9th 06 08:19 PM
how do i view all groups under excel in google groups JulieD Excel Discussion (Misc queries) 2 December 16th 04 04:33 PM


All times are GMT +1. The time now is 10:09 AM.

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

About Us

"It's about Microsoft Excel"