Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return Items from Listbox
I have this code that was bestowed upon me by Tom Ogilvy many moons
ago, that returns all of the times selected in a listbox: Dim varr() icount = 0 for i = 1 to listbox1.Listcount - 1 if listbox1.selected(i) then icount = icount + 1 Redim preserve varr(1 to icount) varr(icount) = listbox1.list(i) End if Next I'd like to return the actual caption. How would I do that? tod |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return Items from Listbox
If you can have multiple items selected, what's the caption?
Option Explicit Private Sub CommandButton1_Click() Dim varr() Dim FoundOne As Boolean Dim iCount As Long Dim i As Long FoundOne = False iCount = 0 For i = 0 To Me.ListBox1.ListCount - 1 If Me.ListBox1.Selected(i) Then FoundOne = True iCount = iCount + 1 ReDim Preserve varr(1 To iCount) varr(iCount) = Me.ListBox1.List(i) End If Next i If FoundOne = True Then For i = LBound(varr) To UBound(varr) MsgBox varr(i) Next i End If End Sub Tod wrote: I have this code that was bestowed upon me by Tom Ogilvy many moons ago, that returns all of the times selected in a listbox: Dim varr() icount = 0 for i = 1 to listbox1.Listcount - 1 if listbox1.selected(i) then icount = icount + 1 Redim preserve varr(1 to icount) varr(icount) = listbox1.list(i) End if Next I'd like to return the actual caption. How would I do that? tod -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Select Multiple Items and return value for Dropdown or listbox | Excel Discussion (Misc queries) | |||
Remove all Listbox items | Excel Programming | |||
Adding Items to a ListBox-Unique Items Only | Excel Programming | |||
Items in a Listbox | Excel Programming | |||
Checking Listbox Items | Excel Programming |