+ Reply to Thread
Results 1 to 3 of 3

Populate an array from Listbox items

  1. #1
    Forum Contributor
    Join Date
    08-20-2019
    Location
    Mumbai
    MS-Off Ver
    Office 365
    Posts
    101

    Populate an array from Listbox items

    Typically I use a variant array to populate a listbox. (i.e. Me.listbox1.list = myArray)

    Now I need to do reverse - fill an array using the multi-column listbox values

    I tried the reverse statement: myArray = me.listbox1.list

    But the array stores only the first ListColumn of the listbox. Any idea how to get this done?

    Basically the objective is to:
    1. store a listbox1 (as original array),
    2. then let the user add or remove listrows
    3. store the updated listbox1 in new array, and
    4. re-produce the original array and new array in two new listboxes on another page of the multi-page userform for comparison purpose.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Populate an array from Listbox items

    Please Login or Register  to view this content.
    That should store a 2-D array in myArray.

    If you see only one dimension in the Locals window, click the + button on one element in the array and you will see the second dimension.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    08-20-2019
    Location
    Mumbai
    MS-Off Ver
    Office 365
    Posts
    101

    Re: Populate an array from Listbox items

    Thanks for waking me up. I had forgotten to change the ColumnCount from 1 to 6. I guess it was a hectic day for me yday and I needed some sleep.

+ 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. How to read table in an array and populate a listbox with the array
    By waimea in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-01-2019, 11:43 AM
  2. [SOLVED] populate listbox with unique items based on criteria in column C
    By bqheng in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2017, 06:55 PM
  3. Replies: 7
    Last Post: 03-12-2017, 03:20 PM
  4. Using vlookup? to populate a listbox with multiple items.
    By msnyder1112 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-27-2016, 11:53 AM
  5. [SOLVED] Duplicate items in Listbox to populate in textbox and change
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2014, 08:36 AM
  6. [SOLVED] Can't populate an array with selected items from listbox
    By jamesdeuce in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2014, 09:57 PM
  7. [SOLVED] Populate Listbox with all rows of a dynamic array where elements of a single array match.
    By Tayque_J_Holmes in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-07-2012, 04:54 AM

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