How to toggle column visibility with a button in Excel?
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:
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:
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.
Now when you click the toggle button, the specified columns are hidden immediately.
While click it again, the columns are displayed.
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.
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.
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
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!