ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Group controls (https://www.excelbanter.com/excel-programming/350080-group-controls.html)

stefantem[_13_]

Group controls
 

How can I group some textboxes and refer each element of group?


--
stefantem
------------------------------------------------------------------------
stefantem's Profile: http://www.excelforum.com/member.php...o&userid=13594
View this thread: http://www.excelforum.com/showthread...hreadid=500081


Peter T

Group controls
 
Use the macro recorder to get syntax how to group your textboxes (edit the
recorded macro of unnecessary "Selects" etc). Then to refer to grouped items
within the group-

Sub test()
Dim gpItem As Object

Set shp = ActiveSheet.Shapes("Group 3")
If shp.Type = msoGroup Then
For Each gpItem In shp.GroupItems
'Debug.Print gpItem.Name
Msgbox gpItem.Name
Next
End If
End Sub

If you have sub-groups within a group would need a recursive type function.

Regards,
Peter T

"stefantem" wrote
in message ...

How can I group some textboxes and refer each element of group?


--
stefantem
------------------------------------------------------------------------
stefantem's Profile:

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




stefantem[_14_]

Group controls
 

The textboxes are in an userform.

dim group1 as New Collection

group1.Add Item....

then refer the elements

How can I use this?


--
stefantem
------------------------------------------------------------------------
stefantem's Profile: http://www.excelforum.com/member.php...o&userid=13594
View this thread: http://www.excelforum.com/showthread...hreadid=500081


Tom Ogilvy

Group controls
 
An example:

Private Sub CommandButton1_Click()
Dim group As New Collection
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.TextBox Then
group.Add ctrl, ctrl.Name
End If
Next
For i = 1 To group.Count
j = Int(Rnd() * group.Count + 1)
group(j).Value = group(i).Name
Next

msgbox Group("Textbox3").Value
End Sub



--
Regards,
Tom Ogilvy


"stefantem" wrote
in message ...

The textboxes are in an userform.

dim group1 as New Collection

group1.Add Item....

then refer the elements

How can I use this?


--
stefantem
------------------------------------------------------------------------
stefantem's Profile:

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





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com