Consulting

Results 1 to 5 of 5

Thread: Solved: N Dimension Arrays

  1. #1

    Solved: N Dimension Arrays

    Hi guys!

    I'm working with an array of 31x63
    Where the 31 rows are for the days of the month and the columns 0 to 60 for the days a taks took to finish. The day in the row indicates the the task was completed.what i need is to obtain the total amount in the columns and rows of tha array.

    I mean I would increase a row in the array to store the total of each column and in a new column i will save the sum of each row.

    if i work with a 1 dimension array i use the instruction application.sum(array) to obtain the total

    but there must be some kind of instruction to do the same but with each column and row of the array, but i just don't know the instruction.

    can anybody help me?

    Thanks!

    Federico

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    An array can be columns and rows!

    Post an example of what you mean, it is not clear.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Assume that from a query i create an array with the following data:
    123 236 258 457 455
    544 847 620 120 233
    322 514 214 625 124
    OK from the aboce message, this array is 3x5.
    And i would like to know if there a function or statment that calculate the sum of the rows, ie row1=123 + 236 + 258 + 457 + 455=1529
    the same for the columns
    what i know is that if you use application.sum(array) the result is the sum of all the elements of the array.
    But i need the sum of each row and column
    Thanks!

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub test()
    Dim ary As Variant
    Dim i As Long

    ary = [{123,236,258,457,455;544,847,620,120,233;322,514,214,625,124}]

    For i = LBound(ary, 1) To UBound(ary, 1)

    Debug.Print "Row " & i & ":= " & Application.Sum(Application.Index(ary, i))
    Next i

    For i = LBound(ary, 2) To UBound(ary, 2)

    Debug.Print "Column " & i & ":= " & Application.Sum(Application.Index(ary, , i))
    Next i
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •