+ Reply to Thread
Results 1 to 2 of 2

What would be the best alternative to the common "List" class in VBA?

Hybrid View

  1. #1
    Registered User
    Join Date
    07-22-2012
    Location
    The Shire
    MS-Off Ver
    Office 2013
    Posts
    51

    What would be the best alternative to the common "List" class in VBA?

    Hello,

    As far as I know there is no "List" variable/class in VBA.
    What I am currently trying to achieve is - I have a range of cells with unique values, I need to pick a few at random and cut them to another range. So far I have a "pick random non-empty cell" function and can cut the selected cell with no problems. However I am worried that cutting too many cells will leave a lot of "blanks" in the original range and with some bad seed (I re-initiate the seed before every run of the random function to ensure higher degree of randomization) it could take Excel a lot of iterations to pick a non-empty cell, which will, albeit slightly, stagger the application.

    If I had a "List" variable, I could simply save the range values in it and delete the picked ones, ensuring the rest will shift to fill the gap. I can do the same by reordering the range, but I was wondering if there isn't a more elegant/professional/better approach to this.


    Your help is appreciated!

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

    Re: What would be the best alternative to the common "List" class in VBA?

    You have collections and dictionary in VBA.
    Collection is part of a built-in function, but not a dictionary.
    Dictionary concept in VBA is very similar to dictionaries in Python and Hash table in Java.
    You have a key-value relationship.
    You could also use collection, but it is not as flexible as dictionary. You need to include on error statement to skip if the key exists on the collection.
    Google them.
    Last edited by AB33; 12-08-2015 at 07:22 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 02-20-2015, 01:13 PM
  2. Put 4th "td" tag for each class name "togo" into cell values
    By b.hill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-27-2014, 10:53 AM
  3. [SOLVED] Formula to pull out data from a list to create "Class Lists"
    By Losguapos1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-16-2014, 10:09 AM
  4. Replies: 0
    Last Post: 03-21-2014, 09:58 AM
  5. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  6. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  7. Replies: 8
    Last Post: 03-07-2011, 01:43 PM

Tags for this Thread

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