Clear a Text Box

Bright01
Bright01 used Ask the Experts™
on
EE Pros,

I have attached a simple WB that has a Textbox on WS1 and a macro I tried to write to clear it and start anew.  Alas, it won't clear.  

Any help would be appreciated.

B.
ClearTextBox.xlsm
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015
Commented:
Try this....

Sub ClearTextbox()
Me.Shapes("TextBox 1").TextFrame.Characters.Text = ""
End Sub

Open in new window

ShumsManaging Director/Excel VBA Developer
Distinguished Expert 2018
Commented:
Try below:
Sub ClearText()
ActiveSheet.Shapes("Textbox 1").TextFrame.Characters.Text = ""
End Sub

Open in new window

Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
@Shums
What is new in your code? :)
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Great job guys. Both solutions work.  It would be handy if you could give me a little more context around the differences in the approaches.

Much thanks!

B.
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome B!
BTW both the solutions were exactly the same if I am not missing something hidden. :)

Author

Commented:
One uses "me.shames" and the other says "activesheet".

B.
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
Since the code was placed on the Worksheet module itself so Me can be used which is equivalent to Sheet1. ActiveSheet.is more generic.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial