Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Making a budget with excel, keep a running total | Excel Discussion (Misc queries) | |||
making a sum total | Excel Discussion (Misc queries) | |||
Old Lotus Sub Total & Grand Total formula | Excel Discussion (Misc queries) | |||
Making charts from arrays in VBA | Charts and Charting in Excel | |||
Making arrays outside cells | Excel Programming |