Subject: iteration
Posted By: bostek Post Date: 8/25/2006 6:45:21 AM
How to iterate through optionButtons in excel Sheet

ex:

For Each oB In Sheet1.OptionButtons ????
   "do smth"
Next


thanx in advance

p.s.
result should be saved in next Sheet cell

regards
Reply By: vemaju Reply Date: 8/28/2006 4:18:38 AM
Hi,
Try this code

Sub IterateObjects()
Dim ob As OLEObject

For Each ob In Sheet1.OLEObjects
    If ob.progID = "Forms.OptionButton.1" Then
        Debug.Print ob.Name
    End If
Next

End Sub

-vemaju
Reply By: bostek Reply Date: 8/28/2006 4:46:27 AM
Hi vemaju thanx for post.

hmmm did u try to get caption property from objects?

regards

quote:
Originally posted by vemaju

Hi,
Try this code

Sub IterateObjects()
Dim ob As OLEObject

For Each ob In Sheet1.OLEObjects
    If ob.progID = "Forms.OptionButton.1" Then
        Debug.Print ob.Name
    End If
Next

End Sub

-vemaju



regards
Reply By: vemaju Reply Date: 8/28/2006 5:09:08 AM
Hi,

You can get Caption property by using ob.Object.Caption

-vemaju
Reply By: bostek Reply Date: 8/28/2006 3:33:42 PM
thanx
it really works.

Just one more question. Why do u have 2 refer to object again in ob.OBJECT.caption
I thought ob.caption is enough? (though I see it in "Locals" when debugging... but please explain if u find some time)

I was doing:

For Each ob In Sheet1.Shapes
    Debug.Print ob.Caption

Next


thanx again for solving my problem vemaju


quote:
Originally posted by vemaju

Hi,

You can get Caption property by using ob.Object.Caption

-vemaju



regards
Reply By: vemaju Reply Date: 8/30/2006 1:23:12 AM
Hi,

You have to refer to OleObjects Object property because the OLEObject has no Caption property itself

-vemaju

Go to topic 48939

Return to index page 190
Return to index page 189
Return to index page 188
Return to index page 187
Return to index page 186
Return to index page 185
Return to index page 184
Return to index page 183
Return to index page 182
Return to index page 181