ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   listboxes (https://www.excelbanter.com/excel-programming/297603-listboxes.html)

Mandy[_2_]

listboxes
 
I have a 3 listboxes, the items in which the user can
click. How can I get make it so that if an item is
clicked in listbox1 then selected items in listboxes 2 &
and 3 are deselected?

Many thanks

Bob Phillips[_6_]

listboxes
 
Hi Mandy,

Is this what you mean?

Private Sub ListBox1_Click()
Me.ListBox2.ListIndex = -1
Me.ListBox3.ListIndex = -1
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mandy" wrote in message
...
I have a 3 listboxes, the items in which the user can
click. How can I get make it so that if an item is
clicked in listbox1 then selected items in listboxes 2 &
and 3 are deselected?

Many thanks




Mandy[_2_]

listboxes
 
Hi Bob,

Yes that's exactly it!
Thanks very much :o)

Hi Mandy,

Is this what you mean?

Private Sub ListBox1_Click()
Me.ListBox2.ListIndex = -1
Me.ListBox3.ListIndex = -1
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mandy" wrote in

message
...
I have a 3 listboxes, the items in which the user can
click. How can I get make it so that if an item is
clicked in listbox1 then selected items in listboxes 2 &
and 3 are deselected?

Many thanks



.


Todd huttenstine

listboxes
 
below code does what I think you need....
To test, paste this entire code in a commandbutton.

Private Sub CommandButton1_Click()
Dim LB1Vals
Dim LB2Vals
Dim LB3Vals


With Worksheets("Worksheet Name Here").ListBox1
For LB1Vals = 0 To .ListCount - 1
If .Selected(LB1Vals) Then
MsgBox "There is an item or items selected
in ListBox1"
'Clears all checks from Listbox2 and
Listbox3
With Worksheets("Worksheet Name
Here").ListBox2
For LB2Vals = 0 To .ListCount - 1
.Selected(LB2Vals) = False
Next LB2Vals
End With
With Worksheets("Worksheet Name
Here").ListBox3
For LB3Vals = 0 To .ListCount - 1
.Selected(LB3Vals) = False
Next LB3Vals
End With
Exit Sub
Else
End If
Next
End With
MsgBox "There were no items selected in ListBox1"
End Sub


Todd Huttenstine


All times are GMT +1. The time now is 02:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com