ListBox "picking the same item repeatedly"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi:

On a UserForm I have the following:

Private Sub ListBox1_Click()
ActiveCell.Value = UserForm1.ListBox1.Value
ActiveCell.Offset(1, 0).Activate

End Sub


And on a Worksheet the following:

Private Sub CommandButton3_Click()
UserForm1.ListBox1.RowSource = "Sheet1!A1:A5"
UserForm1.Show
End Sub


This works ok within its’ limitations but I would like to be able to select
the same item multiple times by clicking it, without moving the cellpointer
to (and by so doing, picking) the next item in the list..

Any suggestions or examples will be greatly appreciated.
Thanks

TK
 
Private Sub ListBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ListBox1.ListIndex = -1
End Sub
 
Thanks again Tom Works great


I also tried to trap the enter key with some VB code but no luck.

Private Sub ListBox1_KeyPress(KeyAscii As Integer)
ListBox1.SetFocus
If KeyAscii = vbKeyReturn Then ActiveCell.Value = UserForm1.ListBox1.Value
End Sub

Would you suggest a fix?

Thanks
 
From help on Keypress:
A KeyPress event does not occur under the following conditions:

· Pressing TAB.
· Pressing ENTER.
· Pressing an arrow key.
· When a keystroke causes the focus to move from one control to another.

Not sure what you are trying to accomplish, but
Try keyup
 
Back
Top