Pull A dimension From An Array

  • Hi Everyone,


    I have the following array:

    Code
    ReDim w(1 to 20,1 to 4)


    Normally I would add the array to the worksheet using:

    Code
    Range("A1").Resize(20, 4) = w


    But in this particular situation I dont want all the values in the first, second and fourth dimension i want to add all the values in w(1 to 20, 3) so to speak.


    Does anyone know how to this?


    Thanks in advance

  • Re: Pull A dimension From An Array


    Hi Andy,


    Thanks for the reply,


    Unfortunately no. That gives me three columns (dimensions) of data when I only want the 3rd (one column).


    If I filled the array completely it would be like this:


    1 21 41 61
    2 22 42 62
    3 23 43 63
    4 24 44 64
    5 25 45 65
    6 26 46 66
    7 27 47 67
    8 28 48 68
    9 29 49 69
    10 30 50 70
    11 31 51 71
    12 32 52 72
    13 33 53 73
    14 34 54 74
    15 35 55 75
    16 36 56 76
    17 37 57 77
    18 38 58 78
    19 39 59 79
    20 40 60 80


    I would like to return the 3rd dimension of the array ie.


    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60


    Thanks again.

  • Re: Pull A dimension From An Array


    Well i can run through the for command ie something like,


    Code
    For i = 1 to 20
     cell(i,1) =w(i,3)
    Next i


    But sometimes the array is very large and more than 4 dimensions which starts to make the loop long.


    Just had convinced myself there woud be a more simple way. Something like that resize.


    Thanks again anyway. Krishnakumar was a bit of a wiz on arrays, sadly tho....hes no longer around.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!