Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Values in multiselect listbox

Hello All!

I am a newbee in vba, so be indulgent.
I create a listbox in a sheet:

With Sheets("Step4")
Set list_Box = .Shapes.AddFormControl(xlListBox, w, x, y, z)
list_Box.ControlFormat.AddItem "1"
list_Box.ControlFormat.AddItem "2"
list_Box.ControlFormat.AddItem "3"
list_Box.ControlFormat.AddItem "4"
list_Box.ControlFormat.MultiSelect = xlSimple
'list_Box.ControlFormat.LinkedCell = .Cells(i, 9).Address

It goes fine, the list box appears, it is mutli-select. But now, I want to
retrieve the selected items, by their names or position.
It seems I can not do list_Box.Selected(i) nor
list_Box.ControlFormat.Selected(i) because it is not an ActiveX listbox. I
can not do .value because it is multi-select, and .LinkedCell does not seem
to work : I just get nothing or 0.

So how can I extract the selected values from my listbox? Please help me.

Olivier


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Values in multiselect listbox

This sub should get you started

Public Sub myList_Change()
Dim msg As String
Dim i As Long
Dim appCaller As String

With ActiveSheet

appCaller = Application.Caller
msg = ""
On Error GoTo end_loop
Do While i < 100
i = i + 1
'.ListBoxes (appCaller)
If .ListBoxes(appCaller).Selected(i) Then
msg = msg & .ListBoxes(appCaller).List(i) & vbNewLine
End If
Loop

end_loop:
On Error GoTo 0
MsgBox msg
End With
End Sub


--
__________________________________
HTH

Bob

"Olivier" wrote in message
...
Hello All!

I am a newbee in vba, so be indulgent.
I create a listbox in a sheet:

With Sheets("Step4")
Set list_Box = .Shapes.AddFormControl(xlListBox, w, x, y, z)
list_Box.ControlFormat.AddItem "1"
list_Box.ControlFormat.AddItem "2"
list_Box.ControlFormat.AddItem "3"
list_Box.ControlFormat.AddItem "4"
list_Box.ControlFormat.MultiSelect = xlSimple
'list_Box.ControlFormat.LinkedCell = .Cells(i, 9).Address

It goes fine, the list box appears, it is mutli-select. But now, I want to
retrieve the selected items, by their names or position.
It seems I can not do list_Box.Selected(i) nor
list_Box.ControlFormat.Selected(i) because it is not an ActiveX listbox. I
can not do .value because it is multi-select, and .LinkedCell does not
seem
to work : I just get nothing or 0.

So how can I extract the selected values from my listbox? Please help me.

Olivier




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Values in multiselect listbox

Thank you! It helps me a lot.

Best regards,

Olivier

"Bob Phillips" wrote:

This sub should get you started

Public Sub myList_Change()
Dim msg As String
Dim i As Long
Dim appCaller As String

With ActiveSheet

appCaller = Application.Caller
msg = ""
On Error GoTo end_loop
Do While i < 100
i = i + 1
'.ListBoxes (appCaller)
If .ListBoxes(appCaller).Selected(i) Then
msg = msg & .ListBoxes(appCaller).List(i) & vbNewLine
End If
Loop

end_loop:
On Error GoTo 0
MsgBox msg
End With
End Sub


--
__________________________________
HTH

Bob

"Olivier" wrote in message
...
Hello All!

I am a newbee in vba, so be indulgent.
I create a listbox in a sheet:

With Sheets("Step4")
Set list_Box = .Shapes.AddFormControl(xlListBox, w, x, y, z)
list_Box.ControlFormat.AddItem "1"
list_Box.ControlFormat.AddItem "2"
list_Box.ControlFormat.AddItem "3"
list_Box.ControlFormat.AddItem "4"
list_Box.ControlFormat.MultiSelect = xlSimple
'list_Box.ControlFormat.LinkedCell = .Cells(i, 9).Address

It goes fine, the list box appears, it is mutli-select. But now, I want to
retrieve the selected items, by their names or position.
It seems I can not do list_Box.Selected(i) nor
list_Box.ControlFormat.Selected(i) because it is not an ActiveX listbox. I
can not do .value because it is multi-select, and .LinkedCell does not
seem
to work : I just get nothing or 0.

So how can I extract the selected values from my listbox? Please help me.

Olivier





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
MultiSelect Listbox StevenD72 Excel Programming 1 September 9th 08 06:43 AM
How do I use a multiselect listbox Neil Murphy Excel Programming 2 November 17th 06 10:00 AM
change combobox values one by one based on selection in multiselect listbox Abdul[_2_] Excel Programming 0 November 7th 06 11:55 AM
Multiselect Listbox use RKS Excel Discussion (Misc queries) 1 May 12th 06 03:04 PM
Multiselect Listbox Francis Ang[_3_] Excel Programming 2 October 25th 04 01:57 AM


All times are GMT +1. The time now is 10:46 PM.

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"