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!

Leave a Reply

Your email address will not be published. Required fields are marked *

Advanced Excel Exercises with Solutions PDF