Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do you sum a particulate dimension in an array? That is I have
2-D Array. I want to sum the 2nd dimension. Normally if it were 1-D would go: ArraySum = Application.WorksheetFunction.Sum(Array) But if Array is a 2-D array, how do I qualify that I only want the 2n dimension summed -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I assume you mean a specifc column in the array.
ArraySum = Application.Sum(Application.Index(Array,0,3)) the above sums column 3. Using 0 as the second argument says use all rows. Here is some sample code: Sub SumArray() Dim rng As Range Dim v As Variant, v1 As Variant Set rng = Range("A1").CurrentRegion v = rng.Value v1 = Application.Index(v, 0, 3) For i = LBound(v1) To UBound(v1) Debug.Print v1(i, LBound(v1, 2)) Next Arraysum = Application.Sum(Application.Index(v, 0, 3)) Debug.Print Arraysum End Sub I believe this will limit you to an array of no larger than 5461 elements. If your array is bigger, I guess you will have to loop through you array and sum up the column yourself. -- Regards, Tom Ogilvy "ExcelMonkey " wrote in message ... How do you sum a particulate dimension in an array? That is I have a 2-D Array. I want to sum the 2nd dimension. Normally if it were 1-D I would go: ArraySum = Application.WorksheetFunction.Sum(Array) But if Array is a 2-D array, how do I qualify that I only want the 2nd dimension summed? --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom Ogilvy wrote:
I assume you mean a specifc column in the array. ArraySum = Application.Sum(Application.Index(Array,0,3)) the above sums column 3. Using 0 as the second argument says use all rows. . . . I believe this will limit you to an array of no larger than 5461 elements. If your array is bigger, I guess you will have to loop through you array and sum up the column yourself. Or, if the functions in the freely downloadable file at http://home.pacbell.net are available to your workbook: ArraySum = Application.Sum(ColumnVector(Array, 3)) The looping is pre-written into the ColumnVector function. Alan Beban |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Applying function after filter is applied | Excel Worksheet Functions | |||
MATCH Function - 2 Dimension Arrays | Excel Worksheet Functions | |||
Using the sum function in a 3 dimension environment | Excel Discussion (Misc queries) | |||
single dimension array | Excel Programming | |||
Dimension problem | Excel Programming |