Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help with Arrays - making a total formula

I have some data..

A - B - C
--------------
a - 1 - 12
a - 2 - 13
a - 3 - 14
b - 4 - 15
b - 5 - 16
b - 6 - 17


i have the code to group the data by column A, and list column B as the
Item Id, with C as the value
all that works fine..

for the group header i have a total. my problem is that I having
trouble making an array for the total of all the totals.

The code itself is a Do loop exiting when there is no more data in the
table to read.

I guess basically what I am asking, is how can I add fields to the
array on the fly, and then reference it at the end and produce a total
of all of my totals.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help with Arrays - making a total formula

I appreciate the prompt response, and thank you for the array code. I
ended up using the subtotal variable like you suggested. Jobs done!
thank you sir

Tom Ogilvy wrote:
Perhaps this pseudo code will give you some ideas

dim subtot() as long
Dim gTot as Long
Dim cell as Range
redim subtot(1 to 1)
for each cell in selection

' your logic which builds the subtotal

subtot(ubound(subtot)) = "your subtotal
redim preserve subtot(1 to ubound(subtot)+1)
Next

for i = lbound(subtot) to ubound(subtot) - 1
gTot = gTot + subtot(i)
Next
msgbox gTot


But unless you need each subtot, why not just use a separate accumulator
variable to build the grandtotal

--
Regards,
Tom Ogilvy


" wrote:

I have some data..

A - B - C
--------------
a - 1 - 12
a - 2 - 13
a - 3 - 14
b - 4 - 15
b - 5 - 16
b - 6 - 17


i have the code to group the data by column A, and list column B as the
Item Id, with C as the value
all that works fine..

for the group header i have a total. my problem is that I having
trouble making an array for the total of all the totals.

The code itself is a Do loop exiting when there is no more data in the
table to read.

I guess basically what I am asking, is how can I add fields to the
array on the fly, and then reference it at the end and produce a total
of all of my totals.



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
Making a budget with excel, keep a running total CMS Excel Discussion (Misc queries) 1 August 5th 08 05:49 PM
making a sum total Abhishek kedia Excel Discussion (Misc queries) 2 April 20th 06 01:36 PM
Old Lotus Sub Total & Grand Total formula Kylie Excel Discussion (Misc queries) 2 April 9th 06 12:24 PM
Making charts from arrays in VBA Ali Baba Charts and Charting in Excel 3 August 30th 05 04:49 PM
Making arrays outside cells tclohesy Excel Programming 2 October 28th 03 01:47 PM


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