• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

clear textbox using cmd button

Amit Modi

Member
I have 10 textbox,,textbox1 to textbox10.
currently I clear as follow one by one.
textbox1.value=""
textbox2.value=""

but its boring to type for every textbox.

please provide short code for the same.
thank you
 
Hi Amit,
something like this?

Code:
Sub Clear_TextBox()
Dim tbx As OLEObject
For Each tbx In ActiveSheet.OLEObjects
If TypeName(tbx.Object) = "TextBox" Then
tbx.Object.Text = ""
End If
Next
End Sub
 
check this..

Code:
dim ctl As Control
For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox"  Then ctl.Value = ""
Next
 
Back
Top