List Box Select All Values

V

Vipul

Hi there,

I have a listbox control on my sheet
Its ListStyle = 1 - fmListStyleOption and it has got 5 items in it as flllows:

All
Red
Green
Blue
Orange

When i select 'All' (the first item) it should select all the items in the
list box.
Can anyone suggest anything on this please?
Thanking in advance.
Vipul Agheda
 
V

Vipul

thanks for replying Joel

MultiSelect property is already fmMultiSelectMulti

i want all the items to be selected automatically when i select only the
first one.
i want to know how can i do it.

can u help with this?
thanks buddy
Vipul
 
A

Andy Pope

Hi,

Paste this code into the sheets code module.

'------------------------
Private m_blnUpdating As Boolean

Private Sub ListBox1_Change()

Dim lngIndex As Long

If m_blnUpdating Then Exit Sub

If ListBox1.ListIndex = 0 Then
If ListBox1.Selected(0) Then
m_blnUpdating = True
For lngIndex = 1 To ListBox1.ListCount - 1
ListBox1.Selected(lngIndex) = True
Next
m_blnUpdating = False
End If
End If

End Sub
'------------------------


Cheers
Andy
 
J

Joel

What is the purpose? Is it for the user to see all the cells selected? A
macro can read all the cells in the box so I'm not sure what your intentions
are. Also how is yu code going to work. Are you going to use a ONClick
routine or is your code going to operate when the user presses a control
button?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top