Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox "picking the same item repeatedly"
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox "picking the same item repeatedly"
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 -- Regards, Tom Ogilvy "TK" wrote in message ... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox "picking the same item repeatedly"
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 "Tom Ogilvy" wrote: 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 -- Regards, Tom Ogilvy "TK" wrote in message ... 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox "picking the same item repeatedly"
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 -- Regards, Tom Ogilvy "TK" wrote in message ... 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 "Tom Ogilvy" wrote: 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 -- Regards, Tom Ogilvy "TK" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
Help importing "Text to Columns" repeatedly | Excel Discussion (Misc queries) |