Assign shortcut key to command button in userform RRS feed

  • Question

  • Hi,

    I would like to assign Ctrl+a short cut keys to select all items in userform listbox.

    Is there a way to do it?


    Guy Zommer

    Tuesday, August 28, 2012 10:46 AM

All replies

  • You could use the accelerator property of a command button which works in conjunction with the Alt key, thus Alt+a.

    You could widen the form and add the button in the wider area and assign the code to the button e.g.

    Private Sub CommandButton1_Click() Dim i as Long For i = 0 To Me.ListBox1.ListCount - 1 Me.ListBox1.Selected(i) = True Next i End Sub

    Then reduce the width of the form to hide the button.

    Graham Mayor - Word MVP

    Tuesday, August 28, 2012 12:14 PM
  • Hi,

    Thanks but I would like to use Ctrl instead of ALT is it possible?

    Guy Zommer

    Tuesday, August 28, 2012 12:52 PM