+ Reply to Thread
Results 1 to 4 of 4

Select matching item in userform combo box

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Select matching item in userform combo box

    I'm trying to select the correct name in a userform combo box. Below i've captured the engineers name in a variable from a separate worksheet, now i want to force the combo box to select the matching name, i can't seem to get this to work any suggestions

    Also any suggestions to eliminate all the repeatative if statements

    Thanks

    If myVar5 = "Bob" Then
        frmPlanning.cboEngineer.List = (.ListIndex = 0)
    End If
    If myVar5 = "Fred" Then
        frmPlanning.cboEngineer.List = (.ListIndex = 1)
    End If
    If myVar5 = "Larry" Then
        frmPlanning.cboEngineer.List = (.ListIndex = 2)
    End If
    If myVar5 = "Steve" Then
        frmPlanning.cboEngineer.List = (.ListIndex = 3)
    End If
    Last edited by jprlimey; 04-22-2014 at 02:16 PM. Reason: Solved

  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,258

    Re: Select matching item in userform combo box

    Hello jprlimey,

    Why not simply do this...
        frmPlanning.cboEngineer.Value = myVar5
    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
    Forum Contributor
    Join Date
    12-22-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007 & 2010
    Posts
    205

    Re: Select matching item in userform combo box

    Leith,

    So simple, i guess "i was too close to the forest to see the tree's"

    Thanks for your assistance, it worked a treat

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

    Re: Select matching item in userform combo box

    Hello jprlimey,

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Add range instead og item to combo in userform
    By Magnet in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2012, 05:54 AM
  2. pre-select VB combo box item
    By finlander in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2011, 07:03 PM
  3. Select combobox item using string matching
    By TheFormerAstronomer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2011, 04:27 AM
  4. Select list item from combo box and add data
    By mli in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-15-2009, 02:08 AM
  5. Auto Select Next Item in Combo Box
    By ssjody in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2006, 02:59 PM

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