How to use button to show hide columns in Excel?

This article will show you methods of creating and using button to show and hide columns in Excel.

Use button to show hide columns with Toggle button
Use button to show hide columns with Kutools for Excel

Use button to show hide columns with 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
    Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub

Note: “F:G” in the code means that columns F:G will be show and hide while running the code. 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 button to show hide columns with Kutools for Excel

If there already have columns hided in your worksheet, Kutools for Excel’s Toggle to unhide / hide all hidden column(s) utility can help you to quickly show and hide them with just one click.

Before applying Kutools for Excel, please download and install it firstly.

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.

  If you want to have a free trial ( 30-day) of this utility, please click to download it, and then go to apply the operation according above steps.

Use button to show hide columns with Kutools for Excel

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

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!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Liz · 2 years ago
    Adding to Ryan's comment, how about hiding a column based on the value of a cell? Basically making the xAdress an IF-function and not a predetermined range of columns.
  • To post as a guest, your comment is unpublished.
    Ryan · 2 years ago
    Hi there, How would you change it to select a bunch of non-adjacent cells?
  • To post as a guest, your comment is unpublished.
    Syed · 3 years ago
    This was very helpful, thanks!