+ Reply to Thread
Results 1 to 2 of 2

Select combobox item using string matching

  1. #1
    Registered User
    Join Date
    05-17-2011
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Select combobox item using string matching

    Hi, this is my first post to this forum. I have a reasonable level of VBA skill, but this one escapes me. Hopefully some seasoned pro can help.

    I have a 2-column combobox on a UserForm, which is populated from a named range in another worksheet. When the UserForm is opened, I want the selected item in the combobox to be based on a string match with a value taken from a textbox in the worksheet, with the string matched to the second column in the combobox.

    So for example, if the values in my combobox are:

    1, Apple
    2, Pear
    3, Orange

    and the value from my textbox is "Orange", I would like to have row 3 selected in my combobox when the form opens.

    I can do this for a one-column combobox using Application.Match and Application.Transpose(ComboBox1.List) (see the code snippet below), but can't get this to work when searching on the second column of the combobox (runtime errors and type mismatches galore).

    Please Login or Register  to view this content.

    I'd really appreciate any help that anyone can provide - this has me tearing my hair out!

  2. #2
    Registered User
    Join Date
    05-17-2011
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Select combobox item using string matching

    So I finally came back to this having left it alone for a while in the hope that it would help, and came up with this solution:

    Please Login or Register  to view this content.

    I haven't fully tested but it seems to work, but I'm not sure that it's the most efficient solution. Was wondering if anyone could suggest any improvements.
    Last edited by TheFormerAstronomer; 05-26-2011 at 05:03 AM.

+ 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