KutoolsforOffice — One Suite. Five Tools. Get More Done.February Sale: 20% Off

How to toggle column visibility with a button in Excel?

AuthorSiluviaLast modified

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:

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

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:

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

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.

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

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.

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

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.

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

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.

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. 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.

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

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

 
Kutools for Excel: Over 300 handy tools at your fingertips! Enjoy AI-powered features for smarter and faster work! 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!

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.

ExcelWordOutlookTabsPowerPoint
  • 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