ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clearing trext box values (https://www.excelbanter.com/excel-programming/430980-clearing-trext-box-values.html)

Risky Dave

Clearing trext box values
 
Hi,

is there a way to clear all the etxtboxes in a form (something like
fmTest.AllTextBoxes.Clear) rather than having to list them individually?

TIA

Dave

ryguy7272

Clearing trext box values
 
There's always a way...

Private Sub cmdNewPT_Click()
Dim C As MSForms.Control
For Each C In Me.Controls
If TypeOf C Is MSForms.TextBox Then
C.Text = ""
End If
Next C
End Sub

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Risky Dave" wrote:

Hi,

is there a way to clear all the etxtboxes in a form (something like
fmTest.AllTextBoxes.Clear) rather than having to list them individually?

TIA

Dave


Rick Rothstein

Clearing trext box values
 
Assuming fmTest is a UserForm, give this code a try...

Dim C As Object
For Each C In Me.Controls
If TypeName(C) = "TextBox" Then C.Text = ""
Next

--
Rick (MVP - Excel)


"Risky Dave" wrote in message
...
Hi,

is there a way to clear all the etxtboxes in a form (something like
fmTest.AllTextBoxes.Clear) rather than having to list them individually?

TIA

Dave



Risky Dave

Clearing trext box values
 
Both,

Many thanks

"Risky Dave" wrote:

Hi,

is there a way to clear all the etxtboxes in a form (something like
fmTest.AllTextBoxes.Clear) rather than having to list them individually?

TIA

Dave



All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com