+ Reply to Thread
Results 1 to 2 of 2

Pulling in values from array; always zero or one.

Hybrid View

  1. #1
    Registered User
    Join Date
    04-06-2010
    Location
    NY
    MS-Off Ver
    Excel 2007
    Posts
    7

    Pulling in values from array; always zero or one.

    What I want to do is pull in specific values from a 3-dimensional array and then calculate the average of those values. Here is a snipet of my code:

    Dim j As Integer, avgTempArray1 As Long, avgTempArray2 As Long, T1 As Long, T2 As Long, tempVal As Long
    For AR = 1 To 19
        T2 = 0
        For i = 1 To numSelectedPrnts
            T1 = 0
            For j = 1 To x
                MsgBox ("ValueArray(j, AR, i) :" & ValueArray(j, AR, i))
                tempVal = ValueArray(j, AR, i)
                MsgBox ("tempVal :" & tempVal)
                T1 = T1 + tempVal
                Next j
            avgTempArray1 = T1 / j
            T2 = T2 + avgTempArray1
            Next i
        avgTempArray2 = T2 / i
        var1Yvals(AR) = avgTempArray2
        Next AR
    When I use MsgBox to check the value of ValueArray(j, AR, i) it returns the proper value of 0.84623, so I know the array is holding the correct value. But once I pass that value to the variable called tempVal, the value of tempVal is 1. I cannot figure out what is going on here... is there some special way you need to get array values from a 3D array?

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Pulling in values from array; always zero or one.

    tempVal is declared as a long, a long can only be a whole number

+ 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