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

Insert a Textbox in an Excel Worksheet

Steps:

  • 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

  • The mouse cursor will change.
  • Click and drag to insert the textbox in the worksheet.

  • Write down a text inside the text box and format it. We wrote down our website name ExcelDemy.

Insert Textbox in Excel Worksheet

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


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

We are going to hide the textbox which we inserted.

Note:

We used Microsoft 365 for the guide.


Step 1 – Launching the Visual Basic Editor Dialog Box

  • 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

  • Adialog box will appear.
  • In the Insert tab on that box, click the Module option.

Selecting the Module option

  • A white empty editor interface will appear.


Step 2 – Using the VBA Code

  • Click on the empty interface.
  • Insert the following code in the box.
Sub Hide_Textbox()
    Sheet1.Shapes("TextBox2").Visible = False
End Sub
  • Press Ctrl + S to save the code.

Our VBA code to hide text box

  • Close the Editor tab.

Step 3 – Run and Get Result

  • In the Developer tab, click on the Macros option.

Launching Macros to run VBA code

  • A new dialog box called Macros will appear.
  • Select the Hide_Textbox option.
  • Click on the Run button to run this code.

  • The textbox will be hidden from the worksheet.

Final result of empty sheet


Download the Practice Workbook


Related Articles

Get FREE Advanced Excel Exercises with Solutions!

Tags:

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

 

 

ExcelDemy
Logo