Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Multi-Select List Box

Hi Everyone,

I have created a multi select list box with options like

All
Option1
Option2
Option3

Now if anyone select the option All, then i don't want to allow anyone
to select other options. I am using Excel 2000. I found this is the
best place to post my query. I have used the below code but it is not
working

for i=0 to listbox1.listcount-1
listbox1.Selected(i) = False
next

Thanks in advance

Cheers

Valli

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multi-Select List Box

I created a userform with a listbox on it and this seemed to work ok:

Option Explicit
Dim BlkProc As Boolean
Private Sub ListBox1_Change()
Dim iCtr As Long
If BlkProc = True Then Exit Sub
If Me.ListBox1.Selected(0) = True Then
BlkProc = True
For iCtr = 1 To Me.ListBox1.ListCount - 1
Me.ListBox1.Selected(iCtr) = False
Next iCtr
BlkProc = False
End If
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
BlkProc = True
.MultiSelect = fmMultiSelectMulti
BlkProc = False
.AddItem "All"
.AddItem "Option1"
.AddItem "Option2"
.AddItem "Option3"
End With
End Sub



wrote:

Hi Everyone,

I have created a multi select list box with options like

All
Option1
Option2
Option3

Now if anyone select the option All, then i don't want to allow anyone
to select other options. I am using Excel 2000. I found this is the
best place to post my query. I have used the below code but it is not
working

for i=0 to listbox1.listcount-1
listbox1.Selected(i) = False
next

Thanks in advance

Cheers

Valli


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Multi-Select List Box

Thanks Dave. I have created the listbox using control toolbox in
worksheet. Also i have tried the above code in Excel 2000, i could
able to select All and the option1, option2.. also.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multi-Select List Box

I put this under the worksheet module that held the listbox:

Option Explicit
Dim BlkProc As Boolean
Private Sub ListBox1_Change()
Dim iCtr As Long
If BlkProc = True Then Exit Sub
If Me.ListBox1.Selected(0) = True Then
BlkProc = True
For iCtr = 1 To Me.ListBox1.ListCount - 1
Me.ListBox1.Selected(iCtr) = False
Next iCtr
BlkProc = False
End If
End Sub
'I used this to populate the listbox
Private Sub Worksheet_Activate()
With Me.ListBox1
BlkProc = True
.MultiSelect = fmMultiSelectMulti
BlkProc = False
.AddItem "All"
.AddItem "Option1"
.AddItem "Option2"
.AddItem "Option3"
End With
End Sub




wrote:

Thanks Dave. I have created the listbox using control toolbox in
worksheet. Also i have tried the above code in Excel 2000, i could
able to select All and the option1, option2.. also.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Multi-Select List Box

On Oct 22, 8:01 pm, Dave Peterson wrote:
I put this under the worksheet module that held the listbox:

Option Explicit
Dim BlkProc As Boolean
Private Sub ListBox1_Change()
Dim iCtr As Long
If BlkProc = True Then Exit Sub
If Me.ListBox1.Selected(0) = True Then
BlkProc = True
For iCtr = 1 To Me.ListBox1.ListCount - 1
Me.ListBox1.Selected(iCtr) = False
Next iCtr
BlkProc = False
End If
End Sub
'I used this to populate the listbox
Private Sub Worksheet_Activate()
With Me.ListBox1
BlkProc = True
.MultiSelect = fmMultiSelectMulti
BlkProc = False
.AddItem "All"
.AddItem "Option1"
.AddItem "Option2"
.AddItem "Option3"
End With
End Sub

wrote:

Thanks Dave. I have created the listbox using control toolbox in
worksheet. Also i have tried the above code in Excel 2000, i could
able to select All and the option1, option2.. also.


--

Dave Peterson


Great Dave..Thanks a lot for your help

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
how do I select multi values from a list Tommy Excel Discussion (Misc queries) 1 July 12th 06 09:38 AM
Last list item selected in a Multi-Select list box? Brian Excel Programming 3 December 5th 05 09:12 PM
multi-select drop down list Priti Excel Programming 1 December 9th 03 12:44 PM
Extract values from a multi-select multi-column list-box Peter[_20_] Excel Programming 5 September 28th 03 04:04 PM
Multi Select List Box jacqui Excel Programming 0 July 22nd 03 12:12 PM


All times are GMT +1. The time now is 11:35 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"