Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Single Dimension Arrays (All)

    I have always thought that defining arrays as:
    myArray(x) and myArray(x,1) were functionally the same thing. However, I've run into a little wrinkle that tells they me they aren't.
    ActiveWorkbook.Sheets(1).Range("F2").Resize(x,1).Value = myArray <font color=red>'works perfectly</font color=red>
    ActiveWorkbook.Sheets(1).Range("F2").Resize(x,).Value = myArray <font color=red>'results in the first value of the array being written to the entire range.</font color=red>
    I wonder if anyone has any suggestions or corrections for my use of arrays.

    TIA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Single Dimension Arrays (All)

    How is your variable myArray defined?

  3. #3
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single Dimension Arrays (All)

    as a variant

    TIA

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Single Dimension Arrays (All)

    Thanks. And how is it populated?

  5. #5
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single Dimension Arrays (All)

    Getting information like pulling teeth? <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    with a for next loop that counts through the number of items and loads them into the array.
    <pre> For intCounter2 = 1 To intRangeSize2
    intMatch = InStr(1, arrExperimentList(intCounter2, 1), strMatch, vbTextCompare)
    If intMatch > 0 Then
    iCount = iCount + 1
    arrPickFileList(iCount) = arrSourceFileList(intCounter1, 1)
    Exit For
    End If
    Next intCounter2
    </pre>

    Or at least that it how it was working. I've now abandoned the single dimension array and gone back to a comfortable two dimension array. Neverthless, my curiosity bone is itching.

    Thanks for any explanation you can offer.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Single Dimension Arrays (All)

    A one-dimensional array seems to be interpreted as a row. If you use

    Range("A1").Resize(1, x) = MyOneDimensionalArray

    each cell will be assigned a different array value, but if you use

    Range("A1").Resize(x, 1) = MyOneDimensionalArray

    each cell will be assigned the first array element.

  7. #7
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Single Dimension Arrays (All)

    Hmmm, I'll have to remember that.

    Thanks

Posting Permissions

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