Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

VBA: Enter Key control?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VBA: Enter Key control?

    In a listbox of item numbers.

    I can successfully mouse click any item number in the list and the matching item is selected on the main sheet.

    If a keyboard letter key is selected the first of the corresponding item numbers that starts with that letter (if any) is selected and I can continue to scroll through those corresponding item numbers by continuing to press the same letter key.

    Butů. the enter key will not select the item the same as mouse clicking will.

    Is it possible to program the enter key to act the same as a mouse click?

    Also, using the keyboard up-down arrow keys will scroll through the items in the list and also select the matching item on the sheet concurrently.

    Is it possible to disable the up-down arrows from having any control on my sheet?

    Thank you

  • #2
    Re: VBA: Enter Key control?

    Hi

    I'm sorry, I don't have a reply to your question, however I am looking for a solution to selecting items in a listbox after keypress

    you wrote

    If a keyboard letter key is selected the first of the corresponding item numbers that starts with that letter (if any) is selected and I can continue to scroll through those corresponding item numbers by continuing to press the same letter key.

    I am interested in how you solved this

    Comment


    • #3
      Re: VBA: Enter Key control?

      Hi,

      Assuming Listbox from the Control toolbox is being used on a worksheet.
      Private Sub ListBox1_Change()
      ' update linked cell when item changed via keypress
      Range(ListBox1.LinkedCell) = ListBox1.Value
      End Sub
      Private Sub ListBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      ' diable arrow key selection
      If KeyCode = 38 Or KeyCode = 40 Then
      KeyCode = vbNull
      End If
      End Sub


      Macrules, the selection by keypress is a built-in function of the listbox from the Control Toolbox. The listbox from the Forms toolbar does not support this.

      Cheers
      Andy

      Comment

      Trending

      Collapse

      There are no results that meet this criteria.

      Working...
      X