View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ryan H Ryan H is offline
external usenet poster
 
Posts: 489
Default Is there a way to test if a control exists on a userform?

I have a sub (ClearUserform) that is called by several userforms. Sometimes
the control may not be on the userform passed to ClearUserform, thus I get an
error. So I added the On Error Resume Next statement to quickly work around
the error. Is there a way to test if the control exists on the userform
passed to the sub.

Sub MySub()
Call ClearUserform(Userform1)
End Sub

Sub ClearUserform(MyForm As UserForm)

On Error Resume Next
MyForm.TextBox1 = ""

' i have other controls list here

On Error GoTo 0

End Sub
--
Cheers,
Ryan