+ Reply to Thread
Results 1 to 4 of 4

creating dynamic number of rows in a listbox

  1. #1
    Registered User
    Join Date
    11-15-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    97

    creating dynamic number of rows in a listbox

    Hi,

    I am writing an application to load the number of members that match a criterion into a ListBox in a Userform. This is a multicolumn array

    To start with I have defined the array with the maximum number of members that can be possibly populated into this list box. However, I find that if the actual number of members is less than the maximum number, blank rows are created in the ListBox. My code is as follows:

    Please Login or Register  to view this content.
    I tried to redim the array using the actual number of records populated which is the value for AryRow

    Please Login or Register  to view this content.
    This always gives me an error.

    Hope some one will be able understand my code and help me with restricting the ListBox entries to the actual records populated

    Anand
    Last edited by anandvh; 06-15-2013 at 09:43 AM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: creating dynamic number of rows in a listbox

    You'll have to test for a blank cell and NOT add that to the array. Or you could do this.
    Please Login or Register  to view this content.
    Since you are already iterating the cells, why not just add them to the listbox as you go? Instead of iterating to add them to the array, then adding them to the listbox.
    Last edited by Tinbendr; 06-15-2013 at 08:40 AM.
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: creating dynamic number of rows in a listbox

    Hi Anand
    you can try something like this
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-15-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    97

    Re: creating dynamic number of rows in a listbox

    thanks tinbendr for your response. When I tried it out, the list box was blank.

    Nilem - Thanks to you also for your response. Your code seemed to work, needed a small tweek to get it running as required. I have not understood the need for the transpose, but will probably get it some time later.

    Anand

+ 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