For...Each loop problem

S

synapse5150

I am trying to loop through all the listboxes I have in an Exce
worksheet (NOT userform), and I'm having problems. If this was
userform, I would use a for each loop (like 'for each control i
userform.controls') but I'm not sure how to translate this collection t
a worksheet. Any ideas
 
S

Simon Lloyd

synapse5150;214061 said:
I am trying to loop through all the listboxes I have in an Exce
worksheet (NOT userform), and I'm having problems. If this was
userform, I would use a for each loop (like 'for each control i
userform.controls') but I'm not sure how to translate this collection t
a worksheet. Any ideas?Which version of excel are you using?, the controls on a worksheet ar
Activex Objects
Perhaps attach a workbook so we can help you directly with that
*Attatchments.
*
To upload a workbook, click reply then add your few words, scroll dow
past the submit button and you will see the Manage Attatchments button
this is where you get to add files for upload, if you have any troubl
please use this link or the one at the bottom of th
any page

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 
S

synapse5150

Thanks, All - you pointed me in the right direction. Here's the solutio
I came up with:

Sub Main_Clear_Selections()
Dim oleList As OLEObject
Dim intI As Integer

For Each oleList In shtMain.OLEObjects
If oleList.OLEType = 2 Then
For intI = 0 T
ActiveSheet.OLEObjects(oleList.Name).Object.ListCount

ActiveSheet.OLEObjects(oleList.Name).Object.Selected(intI) = False

Next intI
End If
Next oleList

End Sub



Couldn't have done it without your help! Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top