+ Reply to Thread
Results 1 to 7 of 7

Select Combobox Item With List Item Select

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Select Combobox Item With List Item Select

    Hi all,

    I've got a combox and a listbox both a worksheet. When I select an item in the
    listbox, I need to setfocus the combox item that value is found in the selected listbox's
    item(String).

    Here's what I have which is not working :

    Please Login or Register  to view this content.

    The code seems to get hung on index value 0

    Any help appreciated.

    Thanks,

    BDB
    Last edited by bdb1974; 04-22-2011 at 02:41 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    21,528

    Re: Select Combobox Item With List Item Select

    Perhaps you're after something along the lines of:

    Please Login or Register  to view this content.
    remove vbTextCompare if you want to maintain case sensitivity.

  3. #3
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Select Combobox Item With List Item Select

    Thanks Donkey Ote, but that's pretty much the same as what I already have....

    The problem seems regardless of what my (i) value should be it get's hung on
    just being (i) = 0.

    If I hard code it to change for a specific value let's say (i) = 2 then
    the combobox will select the item for (i)=2.


    Please Login or Register  to view this content.
    Hmmmm, can't figure out why, other than when I go to select a listbox item
    It hangs on the previous item selected.


    BDB
    Last edited by bdb1974; 04-22-2011 at 12:53 PM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    21,528

    Re: Select Combobox Item With List Item Select

    The code I provided works without issue for me - I'd suggest you post a sample file to demonstrate.

    Incidentally the code I provided is a little different in so far as I compared the value of the selected item in the ListBox to the ComboBox entries rather than the index number.

  5. #5
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Select Combobox Item With List Item Select

    Here's an example i put together.


    HTH's

    BDB
    Attached Files Attached Files

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    21,528

    Re: Select Combobox Item With List Item Select

    Your ComboBox strings are smaller than the ListBox meaning your InStr will never find a match, eg:

    Please Login or Register  to view this content.
    will return 0 whereas

    Please Login or Register  to view this content.
    will return 1

    Reverse the order of your InStr terms and test again
    (This assumes of course you have corrected your terms such that you are now using the Value (string) and not the Index number - didn't check)

  7. #7
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Select Combobox Item With List Item Select

    DonkeyOte,

    Thanks for the great help.

    You are correct! I made the changes and now it seems to be working.


    BDB

+ 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