How to Use VBA to Change Textbox Text in Excel: 3 Easy Methods

 

Method 1 – VBA Changing Textbox Text in Excel

Steps:

  • Go to Insert>Text>Text Box options.

Inserting Textbox to VBA Change Textbox Text in Excel

  • Create the Text box according to your wish.

Result to VBA Change Textbox Text in Excel

  • Write the necessary texts in the text box.

Writing Text to VBA Change Textbox Text in Excel

  • Choose the Visual Basic option in the Developer option.

Opening VBA Window to VBA Change Textbox Text in Excel

  • Go to Insert>Module options to create a VBA window.

Opening New Module in VBA to VBA Change Textbox Text in Excel

  • Insert the following formula in the VBA window.
Sub ChangingTextbox()
Sheets("Changing Textbox").Shapes("textbox 1").TextFrame.Characters.Text = "Ron"
End Sub

Inserting VBA code to VBA Change Textbox Text in Excel

  • Press the Run option or F5 button, get the final result.

Result to VBA Change Textbox Text in Excel

We changed the Text Box text in Excel with VBA. In this way, we can easily change any text with another text or text in the Text box in Excel.


Method 2 – Replacing Letters to VBA Change Textbox Text

Steps:

  • Create a text box with proper text like Method 1.

  • Open the VBA window by following similar steps as Method 1.
  • Insert the following formula in the VBA window.
Sub ReplacingLetter()
Sheet_Name = "Replacing Texts"
Shape_Name = "TextBox 1"
To_be_Replaced = "b"
Replaced_with = "a"
If InStr(1, Sheets(Sheet_Name).Shapes(Shape_Name).TextFrame.Characters.Text, _
To_be_Replaced) <> 0 Then
Sheets(Sheet_Name).Shapes(Shape_Name).TextFrame.Characters.Text _
= Replace(Sheets(Sheet_Name).Shapes(Shape_Name).TextFrame.Characters.Text, _
To_be_Replaced, Replaced_with)
End If
End Sub

  • Get the result where you will find that all the “b” s are replaced with “a.” Thus, you will get the final result accordingly.

Final Result to VBA Change Textbox Text in Excel

Easily replace Text Box text in Excel with VBA. We can easily replace any letter of the text with another letter by using this method.


Method 3 – Using Range Property to VBA Change Textbox Text

Steps:

  • Create a text box with proper text like Method 1.

  • In the B9 cell, insert the input you want to show in the text box.

  • Open the VBA window by following similar steps as Method 1 and then insert the following formula in the VBA window.
Public Sub UsingRangeProperty()
ActiveSheet.Shapes("TextBox 1").TextFrame.Characters.Text = Range("B9").Value
End Sub

  • Get a similar result in the text box as you have inserted input in the B9 cell.

Change the Text Box text by taking the value from a certain cell in Excel with VBA.


Things to Remember

  • The file must be saved as an Excel Macro-Enabled Workbook. Otherwise, the VBA code won’t work.
  • In this case, it is extremely important to remember that in the VBA code, you have to use the worksheet name properly. Otherwise, you won’t get the result accordingly.
  • In some cases, the already used file won’t give the correct results. So, we suggest using a fresh new workbook for these methods.
  • For every case, we suggest downloading the file from our article and going through the article while fulfilling the whole process.

Download Practice Workbook

You can download the practice workbook from here.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!

Tags:

Zehad Rian Jim
Zehad Rian Jim

Zehad Rian Jim is a dedicated professional with a BSc. Degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology. He's good with Microsoft Office and has written more than 80 helpful articles for ExcelDemy in the last year. Now, he makes fun and easy-to-follow Excel tutorials for YouTube as part of the ExcelDemy Video project. Zehad loves figuring out Excel problems, and his passion for learning new things in Excel shines through in... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo