Thread: Form
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Duncan[_5_] Duncan[_5_] is offline
external usenet poster
 
Posts: 290
Default Form

For Each cntrl In Me.Controls
On Error Resume Next
If TypeOf cntrl Is MSForms.TextBox Then
cntrl.Value = "1"
End If
Next cntrl


I think this should do it, havent tested though so post back and let us
know either way.

Duncan


Bill wrote:

Hello,
I have a form that contains a number of text boxes. I would like to add a
loop that sets each text box to an initial value such as 1. Each textbox is
cleverly names TextBox1, TextBox2. I tried a loop like:

For i = 1 to 10
userform1.textbox " & i = 1
next i

But that doesn't work. Any help?

Thanks.

Bill