Skip to main content

How to toggle column visibility with a button in Excel?

Author: Siluvia Last Modified: 2024-11-26

This guide demonstrates how to create a button in Excel that toggles the visibility of specific columns, making it easier to manage and organize your data.

Use a button to toggle column visibility with a Toggle button
Use a button to toggle column visibility with Kutools for Excel


Use a button to toggle column visibility with a Toggle button

You can create a Toggle button to show hide columns by clicking it. Please do as follows.

1. Click Developer > Insert > Toggle Button (ActiveX Control). See screenshot:

A screenshot of the Insert menu showing the Toggle Button (ActiveX Control) in Excel

Note: If you don’t see the Developer tab on the Ribbon, please click show/display developer tab in Excel to know how to enable it.

2. Draw a Toggle button on the worksheet. Right click it, and then select View Code from the right-clicking menu. See screenshot:

A screenshot showing the right-click menu with the View Code option selected in Excel

3. In the opened Microsoft Visual Basic Applications window, replace all content in the code window with below VBA code.

VBA code: button to show hide columns

Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "F:G"
If ToggleButton1.Value Then
    Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
    Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub

Note: “F:G” in the code means that columns F:G will be shown or hidden when the code runs. Please change them to your needs.

4. Press Alt + Q keys simultaneously to close the Microsoft Visual Basic Applications window.

5. Turn off the Design Mode with clicking Developer > Design Mode.

A screenshot showing the Design Mode button on the Developer tab in Excel

Now when you click the toggle button, the specified columns are hidden immediately.

A screenshot showing columns F:G hidden after clicking the toggle button

While click it again, the columns are displayed.

A screenshot showing columns F:G displayed after clicking the toggle button again


Use a button to toggle column visibility with Kutools for Excel

If columns are already hidden in your worksheet, Kutools for Excel’s Toggle to unhide / hide all hidden column(s) utility can help you quickly toggle their visibility with just one click.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

1. Click Kutools > Navigation.

2. Shift to the Column list pane, and then you can click the Toggle to unhide / hide all hidden column(s) button to show/hide columns in current worksheet.

A screenshot of the Column List pane in Excel with the toggle visibility button highlighted

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now


Use a button to toggle column visibility with Kutools for Excel

Kutools for Excel: Over 300 handy tools at your fingertips! Enjoy permanently free AI features! Download Now!

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!