ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   clearing text from text boxes (https://www.excelbanter.com/excel-discussion-misc-queries/41127-clearing-text-text-boxes.html)

Jae

clearing text from text boxes
 
Can someone instruct me on how to create a macro that clears text out of text
boxes (from the control toolbox) please? Thanks in advance.

Bob Phillips

As an example

activesheet.oleobjects("TextBox1").object.text=""

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jae" wrote in message
...
Can someone instruct me on how to create a macro that clears text out of

text
boxes (from the control toolbox) please? Thanks in advance.




Jae

Hi Bob,

I'm not too familiar with VBA. Can you show me what syntax I need to get
this to work?

Thanks again,

Jae

"Bob Phillips" wrote:

As an example

activesheet.oleobjects("TextBox1").object.text=""

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jae" wrote in message
...
Can someone instruct me on how to create a macro that clears text out of

text
boxes (from the control toolbox) please? Thanks in advance.





Chip Pearson

Jae,

The syntax is exactly what Bob posted. E.g.,

Sub AAA()
activesheet.oleobjects("TextBox1").object.text=""
End Sub

Change the "TextBox1" to the name of your text box control.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jae" wrote in message
...
Hi Bob,

I'm not too familiar with VBA. Can you show me what syntax I
need to get
this to work?

Thanks again,

Jae

"Bob Phillips" wrote:

As an example

activesheet.oleobjects("TextBox1").object.text=""

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jae" wrote in message
...
Can someone instruct me on how to create a macro that clears
text out of

text
boxes (from the control toolbox) please? Thanks in advance.







Jae

I also have a number of text boxes. Is there a way to get them all at once?

"Jae" wrote:

Hi Bob,

I'm not too familiar with VBA. Can you show me what syntax I need to get
this to work?

Thanks again,

Jae

"Bob Phillips" wrote:

As an example

activesheet.oleobjects("TextBox1").object.text=""

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jae" wrote in message
...
Can someone instruct me on how to create a macro that clears text out of

text
boxes (from the control toolbox) please? Thanks in advance.





Chip Pearson

No, you can't clear them out with a single line of code. You'll
have to loop through them. For example,

Sub ClearTextBoxes()
Dim OLEObj As OLEObject
For Each OLEObj In ActiveSheet.OLEObjects
If TypeOf OLEObj.Object Is msforms.TextBox Then
OLEObj.Object.Text = ""
End If
Next OLEObj
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Jae" wrote in message
...
I also have a number of text boxes. Is there a way to get them
all at once?

"Jae" wrote:

Hi Bob,

I'm not too familiar with VBA. Can you show me what syntax I
need to get
this to work?

Thanks again,

Jae

"Bob Phillips" wrote:

As an example

activesheet.oleobjects("TextBox1").object.text=""

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jae" wrote in message
...
Can someone instruct me on how to create a macro that
clears text out of
text
boxes (from the control toolbox) please? Thanks in
advance.







All times are GMT +1. The time now is 05:33 AM.

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