How to toggle column visibility with a button in Excel?
Managing large spreadsheets in Excel can often become cumbersome, especially when dealing with extensive datasets that include multiple columns. Displaying only the relevant columns at a particular time not only improves readability but also makes data maintenance easier. This guide explains how to implement a button in your worksheet to toggle the visibility of specific columns, streamlining your workflow for tasks such as reporting, data analysis, or collaborative work where you may need to show or hide particular data segments efficiently.
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
A practical way to control column visibility in Excel is to use a Toggle button, an interactive option that allows you to show or hide specified columns simply by clicking the button. This solution is especially useful in shared data environments, dashboards, or template workbooks where you want users to easily customize their view without manually adjusting the sheet each time.
1. On the Excel Ribbon, go to Developer > Insert > Toggle Button (ActiveX Control). The Developer tab provides various interactive controls including the Toggle Button, which is suited for toggling actions. See screenshot:

Note: If the Developer tab is not visible, you can find detailed steps in show/display developer tab in Excel on enabling this tab. This is required for adding and configuring controls such as Toggle buttons or running macros.
2. After selecting the Toggle Button, draw it anywhere on your worksheet by clicking and dragging with your mouse. Once positioned, right-click the button and choose View Code from the menu to assign actions to the button. Refer to the screenshot:

3. In the opened Microsoft Visual Basic Applications window, you will see a code window associated with your Toggle Button. Completely replace its content with the following VBA code. This script will switch the display state of your chosen columns every time the button is clicked.
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: The designation “F:G” refers to the entire range from column F to column G in the VBA code; if you wish to toggle different columns, simply modify the column references (such as "C:D" for columns C D). Use this approach for quickly customizing which data is included in your toggle.
4. After you have entered the code, press Alt + Q together to exit the Microsoft Visual Basic Applications window and return to your Excel workbook. Ensure any changes are saved before closing if prompted.
5. The Toggle Button will not work until you exit design mode. To do this, return to the Developer tab and click Design Mode to turn it off. When disabled, the button becomes interactive for regular use.

With the setup complete, clicking the Toggle Button will now instantly hide the selected columns F:G, making it very convenient for focusing on key data and reducing clutter.

Each subsequent click will alternate the visibility status, so clicking the button again will restore and show the hidden columns, ensuring quick transitions between different worksheet layouts.

Applicable scenarios for this method include creating interactive templates, dashboards, or forms that require dynamic display options. The main advantage of this solution is ease of use and flexibility, although it does require macro-enabled files and may prompt security warnings depending on your settings. To ensure smooth operation, always save the workbook as a macro-enabled file (.xlsm) and consider informing other users about macro security protocols.
If you encounter issues where the Toggle Button does not respond, check that macros are enabled and that you are not in Design Mode. For more complex needs, you can assign additional controls or adjust the VBA code to handle multiple ranges.
Use a button to toggle column visibility with Kutools for Excel
If your worksheet already contains hidden columns and you want to easily manage their visibility without writing VBA code, Kutools for Excel provides an intuitive utility named Toggle to unhide/hide all hidden column(s). With a single click, you can reveal or hide all hidden columns, making it especially useful for large reports, consolidated sheets, or when working collaboratively and needing quick access to all data.
1. On the Excel Ribbon, select Kutools > Navigation. Kutools enhances Excel’s native features and brings advanced management tools accessible from this custom toolbar.
2. In the Navigation panel, switch to the Column list pane. You will see a clear overview of all columns in the sheet, including hidden ones. To toggle visibility, click the Toggle to unhide/hide all hidden column(s) button. This action will immediately alternate between displaying and hiding all previously hidden columns in your worksheet.

This utility is suited for users looking for a quick, code-free solution and works well for sheets that frequently hide columns to protect sensitive data or simplify presentation. Pros include ease of use, no need for macro permissions, and integration with other useful Kutools features. The only limitation is that you need to have Kutools for Excel installed; its features are not accessible in standard Excel.
Kutools for Excel - Supercharge Excel with over 300 essential tools, making your work faster and easier, and take advantage of AI features for smarter data processing and productivity. Get It Now
Use a button to toggle column visibility with Kutools for Excel
Best Office Productivity Tools
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!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.
- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in