+ Reply to Thread
Results 1 to 3 of 3

help with dynamic combo box

  1. #1
    Registered User
    Join Date
    07-31-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    3

    help with dynamic combo box

    Hi, i want to additems to combobox whenever my userform initialize.
    I chose to use the list property as i have a very long list and using .additem not as efficient.
    What i want my program to do is go to a particular column, then get any data from that column (excluding the column name) and add it to my combo box.
    Basically i think my program logic works, but i am not so familiar with excel practices.

    main issue is why this 2 lines of code will fail me:
    Please Login or Register  to view this content.
    Below is the coding i got.
    Please Login or Register  to view this content.
    error occurs when my productA list is empty. so i debugged and simplified the code to simulate situation when list should be empty and when list contains 1 item:

    Please Login or Register  to view this content.
    error occurs when list is "empty".

    Please Login or Register  to view this content.
    no error occurs when at least 1 item exist.

    Btw the error message is
    Run-time error '381'
    Could not set the List property. Invalid property array index.

    Anyone knows why error occurs when productA is set to Range("P2", "P2")? Thanks alot.
    Last edited by chia0089; 07-31-2009 at 02:40 AM. Reason: mistake when typing here : changed to ,

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: help with dynamic combo box

    Hello Chia,

    Your syntax is wrong in the code below.
    Please Login or Register  to view this content.
    The cell range should be enclosed by a single pair of quotes, like below...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    07-31-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: help with dynamic combo box

    Quote Originally Posted by Leith Ross View Post
    Hello Chia,

    Your syntax is wrong in the code below.
    Please Login or Register  to view this content.
    The cell range should be enclosed by a single pair of quotes, like below...
    Please Login or Register  to view this content.
    Hi thanks for pointing out, that is mistake on my part when i type here. I edited it already.
    productA = Range("P2", "P2")
    Anyway it still doesnt work with the same error message.
    Last edited by chia0089; 07-31-2009 at 02:58 AM.

+ 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