+ Reply to Thread
Results 1 to 3 of 3

newbie question on multi-dimensional array

  1. #1
    Registered User
    Join Date
    04-02-2006
    Location
    nyc
    Posts
    2

    Question newbie question on multi-dimensional array

    Hi all,

    I have a real lame question about multi-dimensional array operation. Suppose I have defined a two-dimensional array "Array(10,10)". If I want to use the Excel function "Average" to compute the average value of Column, say 10, of that 2D array, is there any way to realize it? I tried "Application.Average(Array(:,10))", but apparently the Excel doesn't like that. (You can see I am a Matlab guy, so please don't laugh at me )
    Any comments are extremely welcome.
    search and research

  2. #2
    Jim Cone
    Guest

    Re: newbie question on multi-dimensional array

    s,
    '---------------------
    Sub ArrayTest()
    Dim i As Long
    Dim j As Long
    Dim arrNums() As Double
    Dim arrCol As Variant

    '11 columns
    ReDim arrNums(0 To 10, 0 To 10)
    'Fill the array
    For i = 0 To 10
    For j = 10 To 0 Step -1
    arrNums(i, j) = i + j
    Next
    Next

    'If you set row_num or column_num to 0 (zero), then
    'Index returns the array of values for the entire column or row

    arrCol = Application.Index(arrNums, 0, 10) 'next to last column
    MsgBox Application.Average(arrCol)
    End Sub
    '------------
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware



    "sammus" wrote in message...
    Hi all,
    I have a real lame question about multi-dimensional array operation.
    Suppose I have defined a two-dimensional array "Array(10,10)". If I
    want to use the Excel function "Average" to compute the average value
    of Column, say 10, of that 2D array, is there any way to realize it? I
    tried "Application.Average(Array(:,10))", but apparently the Excel
    doesn't like that. (You can see I am a Matlab guy, so please don't
    laugh at me )
    Any comments are extremely welcome.
    sammus


  3. #3
    Registered User
    Join Date
    04-02-2006
    Location
    nyc
    Posts
    2
    Thank you so much for your enlightening reply.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1