+ Reply to Thread
Results 1 to 7 of 7

Storing different data value in an array

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Storing different data value in an array

    Hello everyone,

    I am trying to go through a random list of numbers, for instance:

    80769
    80769
    80769
    80769
    121435
    121435
    121435
    121435
    114160
    114160
    114160
    114160
    119364
    119364
    119364
    119364
    81634
    81634
    81634
    81634
    51373
    51373
    51373
    51373
    90231
    90231
    90231
    90231
    77601
    77601
    77601
    77601
    109029
    109029
    109029
    109029


    Now, in here, I want to store different values in an array without putting in same data in the array quadriple times, so I would want to store the following data in an array (i.e. 80769, 121435, 114160, 119364, 81634, 51373, 90231, 771601, 109029)

    Help is greatly appreciate and I thank you in advance.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Storing different data value in an array

    I would dump them in to an array and access the ones I wanted

    Myarray= Sheets("Sheet1").Range("A2").CurrentRegion.Value

    You loop through each row/column to access the elements of the array.

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Storing different data value in an array

    Sorry I don't follow, what I would like to do is, for instance, when you put on a auto-filter, if you click the scroll, you would see different elements to the list, that's what I would like to store in the array.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Storing different data value in an array

    You mean

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-10-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Storing different data value in an array

    oh no no, sorry. the array is not fixed, so it would be dynamic, and the numbers would be different for other files so it won't be fixed either.

    So, I would like to go through a random list of numbers, and store the unique elements into an array. Would this be possible through vba?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Storing different data value in an array

    Myarray= Sheets("Sheet1").Range("A2").CurrentRegion
    is a dynamic array. This will show you how many rows and columns(Lower and upper bounds) are stored in the array.
    Each element has an index, to access a particular element, you have to loop through the index and pick that element.
    May be, I misunderstood your request, but that is how I use arrays in my codes.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Storing different data value in an array

    1) No loop but resulting String type array
    Please Login or Register  to view this content.
    2) Returning Variant type array
    Please Login or Register  to view this content.

+ 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