Clear text from text box using VBA

ElBenno

Board Regular
Joined
Jun 3, 2005
Messages
97
Hi,
Does anyone have some code that i can assign to a button to clear the content of a text box in my worksheet?

Kindest Regards,

ben
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

ElBenno

Board Regular
Joined
Jun 3, 2005
Messages
97

ADVERTISEMENT

work sheet is called Breach Form, text box is called TextBox4
 

ElBenno

Board Regular
Joined
Jun 3, 2005
Messages
97
Private Sub Submit_Click()
Dim ws As Worksheet
Dim i As Integer
Set ws = Sheets("Register")

' Return data to the worksheet
With ws
.Range("A4") = TextBox1.Value
.Range("B4") = TextBox2.Value
.Range("C4") = TextBox3.Value
.Range("D4") = TextBox4.Value
.Range("E4") = TextBox5.Value
.Range("F4") = TextBox6.Value
.Range("G4") = TextBox8.Value
.Range("H4") = TextBox10.Value
.Range("I4") = TextBox11.Value
End With
' Clear the TextBoxes
For i = 1 To 11
TextBox(i).Value = ""
Next i

End Sub

This is comming up with the following issue: Compile Error Sub or Function not defined (on the TextBox(i).Value).

thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,108,634
Messages
5,523,996
Members
409,555
Latest member
TIPSAREA

This Week's Hot Topics

Top