Excel allows you to easily hide columns in your worksheet. Once a column is hidden, it will not be shown on the display or printed when you print the worksheet. The column is not deleted; its width is simply reduced to 0. To hide a column, follow these steps:
You can also hide columns by selecting those you want to hide, right-clicking on the selected columns, and choosing Hide from the resulting Context menu.
The columns disappear from the display. Notice, however, that the other columns do not change; they still retain the same column labels. Excel does, however, leave a thick bar in the column header area to indicate where the hidden columns would normally appear.
To later unhide the columns, follow these steps:
You can also unhide columns by selecting the columns on both sides of those you want to unhide, right-clicking on the selected columns, and choosing Unhide from the resulting Context menu.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6864) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Hiding and Unhiding Columns.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
If you open a workbook and find that the width of some of your columns has been changed, the discovery can be ...
Discover MoreNeed a quick way to hide and unhide columns in a worksheet? The shortcuts described in this tip can help fill the bill.
Discover MoreIf you have a bunch of hidden columns in your worksheet, you might want to unhide only a portion of those columns. This ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-09-04 15:57:49
Larry
What is the downside of changing column width to 0.1 to hide it? Existence of hidden column by skip in the headings - e.g., AC when B is hidden.
2020-09-29 14:53:43
Philip
Instead of using a macro to hide predefined columns for printing, why not set up custom views ? Doesn’t require VBA, file format stays xlsx and is easier to maintain (also more versatile as it also supports filtering and print area settings)
2020-09-02 13:50:49
J. Woolley
@Andy
You might want to use my new FindAndUnhide macro in the M_Text module of My Excel Toolbox: https://sites.google.com/view/MyExcelToolbox/
2020-08-21 10:57:23
J. Woolley
@Andy
This might be a bit awkward, but after using Ctrl+F to find the hidden cell, press Esc to close the Find dialog then Ctrl+Shift+9 or Ctrl+( to unhide the row. To re-hide the row, press Ctrl+9. To find the next, press Ctrl+F+Enter.
To hide/unhide a column, use Ctrl+0/Ctrl+Shift+0.
2020-08-19 06:23:47
Andy
I have a large worksheet and use the 'collapse row' function to make it look less busy. Problem is if someone searches for data that is contained within the collapsed rows, the normal Ctrl-F search will find it but just underlines the cell above which is not easy to see. Is there a way of a simple search opening the collpased rows to show the cell containing the searched date?
2017-03-13 18:08:33
Tim J
Why bother with the ribbon, except for unhiding columns?
Surely :
CTRL+9 hide selected row
CTRL+SHIFT+( unhide column in selection
CTRL+0 (zero) hide selected column
However, I have never gotten this to work. Is there a bug?
CTRL+SHIFT+) unhide column in selection
(I also use outlines on sheets I want to hide/unhide rows and columns frequently)
2016-11-29 11:04:11
Gary Lundblad
I like your hiding macro Graham; however; how hard would it be to have the trigger be a value rather than a comment? If the trigger is a value it can be dynamic. How would you change the code if it were say the value "True," in the first column, or even "Hide," if that's easier, rather than a cell comment.
Thank you Graham!
Gary
2016-11-27 02:47:04
Servi
I find it easy to "GROUP" columns or rows (Data-ribbon, outline - Group) that I frequently should hide or unhide. You then get the + and -buttons on the side bar or top bar to expand or collapse grouped columns and rows. You also can "ungroup" rows and columns you do not want to keep into it. Adjoining columns and rows will be "grouped" together. If you want to collapse or expand them separately then it is best to insert a very narrow column or row in between.
Good luck.
2016-11-26 06:27:12
Graham
If you regularly want to hide and unhide a pre-defined set of columns then the macro below could be used. For example I use this to hide some columns during printing.
All that you need to do is add a Comment in Row 1 for any column that you wish to hide. The comment should start with the characters HID, upper or lower case.
NOTE - When creating a new cell comment some versions of Excel start the comment with the user's name. This needs to be removed.
By use of the Static definition the macro toggles between hidden and unhidden.
MACRO HERE
Option Explicit
Static Sub Hiding()
' Hiding Macro
' Toggles a pre-defined selection of columns as hidden or unhidden
' Columns defined by cells in FIRST row having a COMMENT starting with the
' letters "HID", that is any word such as "Hide", "Hidden", "Hiding", etc.
' Checks if Worksheet is initially Protected, asks for password if needed
' but reprotects WITHOUT password.
Dim active_column, actcell, hidden, protected
Application.ScreenUpdating = False ' Runs faster & stops screen flicker
Application.Calculation = xlManual
ActiveWorkbook.PrecisionAsDisplayed = False
If ActiveSheet.ProtectContents Then
protected = "Yes"
ActiveSheet.Unprotect ' Needed to allow hiding/unhiding to occur
End If
Set actcell = ActiveCell ' Stores location of "active" cell
hidden = hidden + 1
' initial value of hidden is zero if "first use" or
' "last used" value, due to "Static" statement in Sub title
If hidden > 2 Then hidden = 1
If hidden = 1 Then ' Change to "all" columns visible
Cells.Select
Selection.EntireColumn.hidden = False
Else ' Change to "selected" columns visible
Selection.SpecialCells(xlLastCell).Activate
active_column = ActiveCell.Column 'Starts search in last column currently in use.
Do While active_column > 0
If UCase(Left(Cells(1, active_column).NoteText, 3)) = "HID" Then
' Any cell in top row with COMMENT starting with
' Hide, Hidden, Hiding, etc. Upper or lower case.
Cells(1, active_column).Select
Selection.EntireColumn.hidden = True
End If
active_column = active_column - 1
Loop
End If
If protected = "Yes" Then
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios _
:=True ' Re-establishes protection, without password
End If
actcell.Select ' Re-establishes active cell position
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True 'Resets screen updating
End Sub
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2022 Sharon Parq Associates, Inc.
Comments