ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List Box Select All Values (https://www.excelbanter.com/excel-programming/417539-list-box-select-all-values.html)

Vipul

List Box Select All Values
 
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

joel

List Box Select All Values
 
Change the property Multiselect

from
fmMultoSelectSingle
to
fmMultiSelectMulti

"Vipul" wrote:

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


Vipul

List Box Select All Values
 
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


"Joel" wrote:

Change the property Multiselect

from
fmMultoSelectSingle
to
fmMultiSelectMulti

"Vipul" wrote:

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


Andy Pope

List Box Select All Values
 
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
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Vipul" wrote in message
...
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



joel

List Box Select All Values
 
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?

"Vipul" wrote:

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


"Joel" wrote:

Change the property Multiselect

from
fmMultoSelectSingle
to
fmMultiSelectMulti

"Vipul" wrote:

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



All times are GMT +1. The time now is 05:00 PM.

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