LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default array of userform controls

Hi Doug

Yes, add them to a custom Collection. Try this on a new userform containing
Textbox1, Textbox2, Textbox3, Textbox4, ...

Option Explicit 'top of userform module

Dim MyControls As Collection

Private Sub UserForm_Initialize()
Set MyControls = New Collection
MyControls.Add Me.TextBox1, "Txt1"
MyControls.Add Me.TextBox2, "Txt2"
MyControls.Add Me.TextBox3, "Txt3"
End Sub

Private Sub CommandButton1_Click()
Dim ctl As MSForms.Control 'or .TextBox
For Each ctl In MyControls
ctl.Text = Now
Next
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
Set MyControls = Nothing
End Sub

HTH. Best wishes Harald

"Doug Glancy" skrev i melding
...
Hello,

Can I define an array of userform controls?



 
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
Grouping Userform Controls ExcelMonkey[_190_] Excel Programming 1 February 23rd 05 02:49 PM
Userform Controls Nigel Excel Programming 5 December 30th 04 01:49 PM
Help please with UserForm controls sa3214 Excel Programming 4 July 2nd 04 03:00 AM
UserForm Controls References Nigel[_4_] Excel Programming 2 October 4th 03 01:55 PM
Add controls to UserForm Vyyk Drago Excel Programming 3 August 26th 03 01:22 PM


All times are GMT +1. The time now is 08:34 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"