Thread: Group controls
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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