LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Looping through listbox controls

for listboxes from the control toolbox toolbar

Dim i as Long
Dim strValue as String
For i = 1 To ActiveSheet.OLEObjects.Count
If TypeOf ActiveSheet.OLEObjects(i).Object is MSForms.Listbox Then
strValue = strValue & ActiveSheet.OLEObjects(i)Object.Value &
", "
End If
Next i
msgbox strValue

--
Regards,
Tom Ogilvy



"Vince" wrote in message
...
Thanks Bob, I tried the following:

Dim i as Long

For i = 1 To ActiveSheet.OLEObjects.Count
If TypeName(ActiveSheet.OLEObjects(i).Object) = "ListBox" Then
strValue = ActiveSheet.OLEObjects(i).Value
End If
Next i

First problem is the If statement never goes true.
Second problem is the line strValue when looked at in the quick watch

window
gives the error: <Object doesn't support this property or method

Any idea what is going on?

Vince
"Bob Phillips" wrote:

You are probabky looking at userform answers.

Try

Dim i As Long

For i = 1 To ActiveSheet.OLEObjects.Count
If TypeName(ActiveSheet.OLEObjects(i).Object) = "ListBox" Then
Msgbox ActiveSheet.OLEObjects(i).Name
End If
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Vince" wrote in message
...
I have a worksheet with 51 listbox controls on it, Listbox1 -

Listbox51.
I
need to loop through them and get the Value in each one and store it

away.
I
have looked through the questions posted here, and the answer appears

easy
enough, however, I don't know if I have an Excel problem or something

else.
For some reason the Me.Controls line of code will not work. When I am


typing
the line of code, the drop down gives me several properties and

methods to
use for the "Me." but not "Controls".
Can anyone provide some help with this!!

Thank you
Vince






 
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
Looping through controls on form Robbyn Excel Programming 2 March 15th 05 02:37 PM
Problem with looping through userform controls Jeremy Gollehon[_2_] Excel Programming 5 February 17th 05 05:41 PM
looping through userform controls JulieD Excel Programming 2 August 14th 04 02:13 PM
Looping through multiple controls rci Excel Programming 2 March 4th 04 08:43 PM
Looping thru custom controls papou[_6_] Excel Programming 2 July 23rd 03 04:14 PM


All times are GMT +1. The time now is 02:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"