Method 1 – VBA Changing Textbox Text in Excel
Steps:
- Go to Insert>Text>Text Box options.
- Create the Text box according to your wish.
- Write the necessary texts in the text box.
- Go to Insert>Module options to create a VBA window.
- Insert the following formula in the VBA window.
Sub ChangingTextbox()
Sheets("Changing Textbox").Shapes("textbox 1").TextFrame.Characters.Text = "Ron"
End Sub
- Press the Run option or F5 button, get the final result.
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.
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
- How to Make Textbox Datepicker with Excel VBA
- How to Hide Textbox Using Excel VBA
- How to Use Excel VBA Textbox Events
- How to Format TextBox for Phone Number in Excel VBA