+ Reply to Thread
Results 1 to 8 of 8

Excel Double Click/Enter Listbox

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Excel Double Click/Enter Listbox

    Hello Everyone,

    I have a listbox1 in the userform and I want to be able to use either the double clicking from the mouse or use an "enter" key.
    I already have a code for double click but I need to add the enter key code with it.
    Please help. Thank you.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,251

    Re: Excel Double Click/Enter Listbox

    Try this event:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Excel Double Click/Enter Listbox

    sorry, it did not work.
    received a debugged error:
    on this code:

    UserForm1.TextBox1.Value = UserForm1.ListBox1.Value

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,251

    Re: Excel Double Click/Enter Listbox

    Quote Originally Posted by RJ1969 View Post
    it did not work.
    received a debugged error:
    1. Maybe your UserForm has a different name, should be UserForm1 - see enclosure "Book1.xls"
    2. Have you selected the appropriate references in the vba editor ? - see pictures (new excels can have a higher numbering)
    3. From contextual help vba:
    "The KeyDown and KeyUp events do not occur under the following circumstances:
    - The user presses enter on a form with a command button whose Default property is set to True.
    - The user presses esc on a form with a command button whose Cancel property is set to True."
    Attached Images Attached Images
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Excel Double Click/Enter Listbox

    Hi Porucha,
    Ok.. I did change the userform name. Is there anyway to add a tabbing with the code so that that I can tab it and press enter?

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,251

    Re: Excel Double Click/Enter Listbox

    You don't need doing it programmatically (TAB or SHIFT+TAB):

    1. Right click on the project of UserForm and select "Tab Order" and set objects sequence

    or

    2. From Ms contextual help: "Set the tab order using the "TabIndex" property
    a. Identify the tab order you want to use for the form.
    The tab index of the first control in the tab order is 0; the tab index of the second is 1, and so on
    b. Select a control in the tab order
    c. In the Properties window, select the TabIndex property
    d. Enter the appropriate number to identify the control's position in the tab order
    "

    but if you will programmatically use "TabIndex" property:

    e.g.:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Excel Double Click/Enter Listbox

    Hi Porucha,
    So far this is what I have in the userform. I can double click it and I can use a down arrow then press enter.
    I have a textbox1 where I type "app" for applesauce and it will filter whatever that has "app" from the listbox1 but when I press tab it does not highlight the item when I tab it.
    thanks.


    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,251

    Re: Excel Double Click/Enter Listbox

    Quote Originally Posted by RJ1969 View Post
    1. I can double click it and I can use a down arrow then press enter.
    2. I have a textbox1 where I type "app" for applesauce
    3. and it will filter whatever that has "app" from the listbox1
    4. but when I press tab it does not highlight the item when I tab it.
    To 2. and 3.
    a) simply typing any text in 'textbox' does not filter 'listboxes', you must have suitable code

    To 4.
    a) if you have one, then if you type something in 'textbox' and the list in 'listbox' will be filtered, what should be highlighted there ?
    b) if in 'textbox' you have typed e.g. "appl" and on the filtered list you have: "applesauce", "application", "apple", etc. and you press tab key, how does code know that what you want to highlight ... "appl" <==> "applesauce", "application", "apple" ?

    Please provide your sample file.

    Additionally:
    Please Login or Register  to view this content.
    1. "If KeyCode = 13" <==> if you press enter
    2. "ListBox1.ListIndex - 1" <==> "ListBox1.ListIndex" it is a number, Long type, if equal "3" then "ListBox1.ListIndex - 1" = "2", and "2" is always TRUE. This is needless/superfluous in this place.
    Please Login or Register  to view this content.
    Should be
    Please Login or Register  to view this content.
    Sorry for bad english

    And yet sample code to filtering the list from field 'textbox':
    Please Login or Register  to view this content.

+ 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. [SOLVED] Double-click a listbox inside a group
    By rodgersmg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2015, 08:23 AM
  2. [SOLVED] Move rows from one listbox to another by double click
    By Littlefarmer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2015, 10:39 AM
  3. Formula not executing unless i double click and enter it!!!
    By meus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2015, 12:07 AM
  4. [SOLVED] Double Click Listbox question
    By frostii in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2015, 09:15 PM
  5. [SOLVED] Double-click cell to enter TODAY ()
    By Tanyab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-12-2013, 05:43 AM
  6. Double click on cell and enter data
    By lpratt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2012, 03:50 AM
  7. double click option in listbox outputs to cell in excel 97 !
    By spyrule in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2006, 12:05 AM

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