Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Help importing "Text to Columns" repeatedly Nightsky Excel Discussion (Misc queries) 1 December 2nd 05 03:28 AM


All times are GMT +1. The time now is 07:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"