HOW LOOP through the textboxes? Please Help.


Posted by Larry on November 24, 2000 12:47 PM

Please help!

I need Loop through matrix of textboxes in VBA Excel and I need to set appropriate Textboxes as Visible=False.
I made 10 Textboxes called OTdeg1, OTdeg2, etc. till 10 on userform.


Ihave tried this:

Dim i As Integer
Dim OTdeg as Textbox

For i = 1 To 10
With Me
OTdeg(i).Visible = False
End With
Next i

But I still get this Error:

Runtime error '91'
Object variable or with block variable not set
-------------------------------------------------

I really cant understand what does it mean.

Have you any idea?
Thanks for any response.



Posted by Ivan Moala on November 24, 2000 4:11 PM


Try this instead

Dim TB As Control

For Each TB In Me.Controls
If InStr(1, TB.Name, "OTDeg") > 0 Then
TB.Visible = False
End If
Next


Ivan