Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2006, 06:45 AM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default iteration

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
__________________
regards
 
Old August 28th, 2006, 04:18 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old August 28th, 2006, 04:46 AM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi vemaju thanx for post.

hmmm did u try to get caption property from objects?

regards

Quote:
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
 
Old August 28th, 2006, 05:09 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

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

-vemaju
 
Old August 28th, 2006, 03:33 PM
Authorized User
 
Join Date: Jul 2004
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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:
quote:Originally posted by vemaju
 Hi,

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

-vemaju
regards
 
Old August 30th, 2006, 01:23 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

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

-vemaju




Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox Conditional Iteration caterpillar ASP.NET 1.0 and 1.1 Basics 5 September 1st, 2006 05:36 PM
iteration movenext weazy Excel VBA 0 June 9th, 2006 05:56 PM
Picture iteration bahachin Excel VBA 3 September 28th, 2005 12:44 PM
Iteration in struts sridevi Servlets 2 July 1st, 2005 07:01 AM
Iteration through a dropdown. tryxxter PHP How-To 1 February 9th, 2005 11:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.