Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Loop through objects/controls on worksheet

Hi all

I'm sure this is possible but I don't know the proper
syntax.

I'd like to loop through all the command buttons (or
other controls such as option buttons) on a worksheet and
capture their names. Is this possible?

Any help would be appreciated!
Thanks a lot!

Tom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Loop through objects/controls on worksheet

Hi Tom

If you use controls from the control toolbox then try this

Sub test1()
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CommandButton Then
MsgBox obj.Name
End If
Next
End Sub

Sub test2()
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CheckBox Then
'obj.Object.Value = True
MsgBox obj.Name
End If
Next
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Tom V" wrote in message ...
Hi all

I'm sure this is possible but I don't know the proper
syntax.

I'd like to loop through all the command buttons (or
other controls such as option buttons) on a worksheet and
capture their names. Is this possible?

Any help would be appreciated!
Thanks a lot!

Tom



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Loop through objects/controls on worksheet

Thanks a lot for the quick response Ron!!

-----Original Message-----
Hi Tom

If you use controls from the control toolbox then try

this

Sub test1()
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CommandButton Then
MsgBox obj.Name
End If
Next
End Sub

Sub test2()
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CheckBox Then
'obj.Object.Value = True
MsgBox obj.Name
End If
Next
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Tom V" wrote in

message ...
Hi all

I'm sure this is possible but I don't know the proper
syntax.

I'd like to loop through all the command buttons (or
other controls such as option buttons) on a worksheet

and
capture their names. Is this possible?

Any help would be appreciated!
Thanks a lot!

Tom



.

Reply
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
loop through form objects Steven K Excel Programming 1 August 23rd 04 07:47 PM
loop through controls libby Excel Programming 0 August 14th 04 12:41 PM
Limitation on controls/objects? Dave Peterson[_3_] Excel Programming 1 August 14th 04 01:16 AM
Controls on worksheet gr8guy Excel Programming 1 May 1st 04 03:11 AM
Vision Objects as Controls? Tom Ogilvy Excel Programming 0 April 21st 04 04:07 PM


All times are GMT +1. The time now is 12:19 PM.

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"