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


Is there a way to loop through controls (e.g. vb checkBox) that are o
the worksheet. I know you can do this for the userForm as follows

For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "CheckBox" Then
MsgBox CheckBox.Text
End If
Next ctrl

Is this possible for an active worksheet

--
cmpcwil
-----------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...fo&userid=3341
View this thread: http://www.excelforum.com/showthread.php?threadid=53261

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default looping through controls


Hope this is what you are after.

Sub erm()

Dim mycntrl As OLEObject
Dim sht As Worksheet

Set sht = ActiveSheet

For Each mycntrl In sht.OLEObjects

MsgBox mycntrl.Name

Next mycntrl


End Sub


Pet

--
Peter8
-----------------------------------------------------------------------
Peter81's Profile: http://www.excelforum.com/member.php...fo&userid=2535
View this thread: http://www.excelforum.com/showthread.php?threadid=53261

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default looping through controls

If they are forms toolbar checkboxes, then use

Dim ctrl As CheckBox
For Each ctrl In ActiveSheet.CheckBoxes
MsgBox ctrl.Name
Next ctrl


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Peter81" wrote in
message ...

Hope this is what you are after.

Sub erm()

Dim mycntrl As OLEObject
Dim sht As Worksheet

Set sht = ActiveSheet

For Each mycntrl In sht.OLEObjects

MsgBox mycntrl.Name

Next mycntrl


End Sub


Pete


--
Peter81
------------------------------------------------------------------------
Peter81's Profile:

http://www.excelforum.com/member.php...o&userid=25353
View this thread: http://www.excelforum.com/showthread...hreadid=532616



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default looping through controls


Thanks for all your help, just what I needed!


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=532616

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default looping through controls

I think you have to do it by specific type of control, eg TextBox

"cmpcwil2" wrote:


Is there a way to loop through controls (e.g. vb checkBox) that are on
the worksheet. I know you can do this for the userForm as follows

For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "CheckBox" Then
MsgBox CheckBox.Text
End If
Next ctrl

Is this possible for an active worksheet?


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=532616




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
Looping through controls Libby Excel Programming 1 April 27th 05 04:13 PM
Looping through controls on form Robbyn Excel Programming 2 March 15th 05 02:37 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 06:18 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"