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
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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
 
Upvote 0

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top