ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Apple to Orange (https://www.excelbanter.com/excel-programming/331604-apple-orange.html)

MattShoreson[_26_]

Apple to Orange
 

Well not quite - but nearly. (In addendum to prev thread)

I have 5 multiselect listboxes on a userform. I want to retreive
results of all boxes to a seperate range on a worksheet. So far I
have....

Sub EvaluateListboxes()
Dim moctBox As Control
For Each moctBox In MainMenu.Controls
If TypeName(moctBox) = XL_MENU_LISTBOX Then
RetrieveList moctBox
End If
Next moctBox
End Sub

Sub RetrieveList(ByVal mlstBox As Variant)
Dim lngIndex As Long
With mlstBox
For lngIndex = 0 To .ListCount - 1
If .Selected(lngIndex) Then
MsgBox .List(.lngIndex)
End If
Next lngIndex
End With
End Sub

the problem is that .listcount is only a property of a listbox not a
control. Yet you can only cycle thru the listboxes on a form using
controls? How do I turn my proverbial apple into an orange?

CIA,
Matt.


--
MattShoreson
------------------------------------------------------------------------
MattShoreson's Profile: http://www.excelforum.com/member.php...fo&userid=3472
View this thread: http://www.excelforum.com/showthread...hreadid=378564


MattShoreson[_27_]

Apple to Orange
 

there was a dot infront of lngIndex

MsgBox .List(.lngIndex) should be MsgBox .List(lngIndex

--
MattShoreso
-----------------------------------------------------------------------
MattShoreson's Profile: http://www.excelforum.com/member.php...nfo&userid=347
View this thread: http://www.excelforum.com/showthread.php?threadid=37856



All times are GMT +1. The time now is 07:31 AM.

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