+ Reply to Thread
Results 1 to 8 of 8

userForm listBox being double-loaded

  1. #1
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    userForm listBox being double-loaded

    Howdy, Folks:

    I'm having problems loading data into a listbox. When the form first opens, it loads the data twice. I can then kill the form and restart it and the data is in there three times. I can't see any loading problems with the userForm_initialize routine. How can I ensure that the listBox is empty before I start adding data? This would also seem to be necessary prior to loading a different set of data into the form - correct?

    Any ideas?

    TIA.

    Bob
    Last edited by bstubbs; 07-16-2009 at 06:39 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: userForm listBox being double-loaded

    Any ideas?
    Probably, once you post your workbook with the code.

  3. #3
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: userForm listBox being double-loaded

    Here's the concerned code:

    Please Login or Register  to view this content.
    Here's then initialize section:

    Please Login or Register  to view this content.
    The data is in the "lookupData" sheet, within the "cedarHillDriverList" range. The range is defined by:

    Please Login or Register  to view this content.
    It appears to be working correctly as well.

    Any ideas now?

    Bob

  4. #4
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: userForm listBox being double-loaded

    Isn't the critical point about how to empty the list. Something like
    "Me.lbSelectDriver.removeAll".

    How can I accomplish that sort of thing?

    Thanks.

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: userForm listBox being double-loaded

    I don't see why you dont just set the RowSource property to the named range inside the property sheet.

    As stands now, the list loads as follows:

    Upon initialization of the form
    Every button click while the form is open - which duplicates the items in the list with every click.



    I think it is simpler and cleaner to just assign the RowSource property. Since you're using a DNR, the list will always update per changes. Why go to the trouble of using code to loop through the cells in the range?
    Last edited by Palmetto; 07-16-2009 at 03:16 PM.

  6. #6
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: userForm listBox being double-loaded

    Ok - i'm always up for "easy".

    BTW - "DNR"?

    Bob

  7. #7
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: userForm listBox being double-loaded

    DNR = dynamic named range.
    Got lazy . . . . . . with typing.

  8. #8
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: userForm listBox being double-loaded

    Worked like a champ. Thanks for your help.

    Bob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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