+ Reply to Thread
Results 1 to 5 of 5

Problem with combo-box

Hybrid View

asgerali Problem with combo-box 09-06-2011, 04:39 AM
royUK Re: Problem with combo-box 09-06-2011, 07:38 AM
asgerali Re: Problem with combo-box 09-07-2011, 12:42 AM
Leith Ross Re: Problem with combo-box 09-07-2011, 12:50 AM
asgerali Re: Problem with combo-box 10-05-2011, 06:46 AM
  1. #1
    Registered User
    Join Date
    09-06-2011
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Problem with combo-box

    I have 3 drop downs in my sheet.
    The first one is a form control (drop down list) which has 3 entries. Depending on what is selected in the first drop down, a macro is run to populate the second.

    The second one is an activex control (combo box). I need a combo box because the list is going to be very long (probably 500+ entries) and the user needs to be able to type in the first few characters to minimise the scrolling effort.
    Now, depending on what is selected here, a macro needs to run to populate the third drop down.

    The problem I'm facing is this. The only way to assign a macro to a combo box is to code it in the worksheet. When I do it as a Combobox_Change() function, it runs everytime the user types even one alphabet. (The macro is a little slow, so it's not preferable)
    If I use the Combobox_Click() function, the macro runs only if the user clicks on it. Typing it out doesn't do the trick.

    Is there a way the combobox can detect an 'Enter' being pressed? If there is some other type of control that I could use, that is fine too. As long as the basic requirement of being able to type in the drop down is satisfied.

    Thanks in advance

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problem with combo-box

    Maybe you could use the Lost_Focus event
    Private Sub ComboBox1_LostFocus()
    'macro name here
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-06-2011
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Problem with combo-box

    Doesn't work
    LostFocus() works when the user clicks somewhere outside the combo box. Pressing the enter key doesn't trigger it.

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

    Re: Problem with combo-box

    Hello asgerali,

    You can use the KeyUp event to detect the Enter key. Here is an example that beep when the enter is pressed.
    Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      If KeyCode = 13 Then
         Beep
      End If
    End Sub
    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!)

  5. #5
    Registered User
    Join Date
    09-06-2011
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Problem with combo-box

    Hi Leith,

    I know I'm a little late in saying this, but thanks a million! You can't imagine how much of a help you've been. I guess I forgot in the jubiliation after i saw that it worked :D

    In retrospect, I feel kinda stupid not having figured it out myself.

    Thanks

+ 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