How to Hide Textbox Using Excel VBA (with Quick Steps)

A textbox is a common element in an Excel spreadsheet to add notes or additional information. However, sometimes we need to hide this textbox from the worksheet. Using the visual-basic code, we can perform such an operation efficiently. In the article, we are going to demonstrate the step-by-step procedure to hide the textbox using Excel VBA. If you are also curious about it, download our practice workbook and follow us.

Insert Textbox in Excel Worksheet

Before showing the textbox hiding procedure, we will first demonstrate to you how to insert a textbox in Excel. The steps of this process are given below:

📌 Steps:

  • First of all, in the Insert tab, click on the Text Box command from the Text group.

Choose Text Box command to insert a text box which we will hide later

  • You will notice that the mouse cursor will change.
  • Now, drag your mouse to insert the textbox in the worksheet.
  • The textbox will appear in front of you.

  • After that, write down a text inside the text box and format it according to your desire. Here, we write down our website name ExcelDemy.

Insert Textbox in Excel Worksheet

  • Our textbox is ready.

Read More: How to Add Text to Textbox Using Excel VBA

Step-by-Step Procedure to Hide Textbox Using Excel VBA

Now, we will demonstrate to you the step-by-step procedure to hide the textbox using the VBA in Excel. We are going to hide the textbox which we inserted a while ago.

📚 Note:

All the operations of this article are accomplished by using the Microsoft 365 application.

Step 1: Launching Visual Basic Editor Dialog Box

In the first step, we are going to launch the Visual Basic Editor dialog box so that we can write a VBA code to hide the textbox in Excel.

  • To start the approach, go to the Developer tab and click on Visual Basic. If you don’t have that, you have to enable the Developer tab. You can also press ‘Alt+F11’ to open the Visual Basic Editor.

Opening VBA editor dialog box to hide textbox

  • As a result, a dialog box will appear.
  • Now, in the Insert tab on that box, click the Module option.

Selecting the Module option

  • Then, a white empty editor interface will appear in front of you.

  • Our first job is completed.

Thus, we can say that we have completed the first step of our task to hide the textbox.

Step 2: Writing Suitable VBA Code

In this step, we will write down the VBA code, which will hide the textbox from our worksheet.

  • At first, click on the empty interface.
  • Now, write down the following code in the box.
Sub Hide_Textbox()
    Sheet1.Shapes("TextBox2").Visible = False
End Sub
  • After that, press ‘Ctrl+S’ to save the code.

Our VBA code to hide text box

  • Then, close the Editor tab.

Hence, we can say that we have accomplished the second step of our task to hide the textbox.

Step 3: Run and Get Result

In the last step, we will run the VBA code and hide our textbox.

  • First, in the Developer tab, click on the Macros option.

Launching Macros to run VBA code

  • A new dialog box called Macros will appear.
  • Now, select the Hide_Textbox option.
  • Afterward, click on the Run button to run this code.

  • You will notice that the textbox will be hidden from the worksheet.

Final result of empty sheet

Finally, we can say that our VBA code works successfully, and we are able to hide the textbox from our Excel spreadsheet.

Download Practice Workbook

Download this practice workbook for practice while you are reading this article.


That’s the end of this article. I hope that this article will be helpful for you and you will be able to hide the textbox using Excel VBA. Please share any further queries or recommendations with us in the comments section below if you have any other questions or recommendations. Keep learning new methods and keep growing!

Related Articles

Get FREE Advanced Excel Exercises with Solutions!


Soumik Dutta
Soumik Dutta

Soumik Dutta, having earned a BSc in Naval Architecture & Engineering from Bangladesh University of Engineering and Technology, plays a key role as an Excel & VBA Content Developer at ExcelDemy. Driven by a profound passion for research and innovation, he actively immerses himself in Excel. In his role, Soumik not only skillfully addresses complex challenges but also demonstrates enthusiasm and expertise in gracefully navigating tough situations, underscoring his unwavering commitment to consistently deliver exceptional, high-quality content that... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF