Question Locked

How to Hide Columns in Excel

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a worksheet with checkboxes. When a user selects a checkbox, another sheet is populated with the information relevant to that checkbox. Say for example, in Sheet A there are three checkboxes, one is Apples, one is Organges and the other is Grapefruits. In sheet B is a column with apples in COL A, organes in COL B and bananans In COL C and the differnt places where the fruit can be purchased is listed in each row. A user comes and places a checkmark in apples and bananas, How can I automatically hide the column for bananas for ease of printing?

8 replies

by peconet tietokoneet

These instructions show you how to hide columns by right clicking on the column header.

The column header is the gray bar along the top edge of the worksheet containing the column letters.

Hide Columns in an Excel Worksheet

When you hide a column in a worksheet, data in that column can still be used and referenced in the worksheet.

To hide a single column

1. Right click on the column header of the column to be hidden.
2. Choose Hide from the menu.
3. The selected column and the column letter will be hidden from view.

To hide adjacent columns in the worksheet

For example, you want to hide columns C, D, and E.

1. In the column header drag select to highlight all of the columns you want to hide.
2. Right click on the selected columns.
3. Choose Hide from the menu.
4. The selected columns and column letters will be hidden from view.

To hide separated columns in the worksheet

For example, you want to hide columns B, D, and F.

1. In the column header left click on the first column to be hidden.
2. Press and hold down the CTRL key on the keyboard.
3. Continue to hold down the CTRL key and left click on the rest of columns to be hidden.
4. Right click on one of the selected columns.
5. Choose Hide from the menu.
6. The selected columns and column letters will be hidden from view.
Hope all goes well..

by larryd4

The hidden option for the column is a programmable feature. You should be able to write a VBA script in Excel that triggers when you check the "check" box for bananas that sets the hidden attribute for the specified columns.

Here is the basic code to hide columns. Not that you have to tell Excel to update the screen, the last line, to reflect the change of the hidden attribute.

Application.ScreenUpdating = False
ActiveSheet.range("o1:iv1").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.range("A275:A5000").Select
Selection.EntireRow.Hidden = True
Application.ScreenUpdating = True

by larryd4

That these column settings will be saved as a setting with the file, if the columns are not set back after being hidden. So you will need to programmatically set them back at some point.

by khale

Thanks Larry!

Sorry for the delay! I have one more question. I am excel savvy but I do not know much about VBA. Do I just copy and paste this VBA into my worksheet? Could you explain a little more to me about what to do?

by larryd4

VBA is script language with in Office. It was designed to allow a more programmatic way to manipulate the Office applications.

Under Tools and then Macros you will find the VB Editor and the location where you create the script. Then you need to link a button, a drop down, or even the act of selecting a cell to run the script. Might be smart to pick up a book on Excel Scripting.

Sorry about the late response, works been kinda busy..

This discussion is closed to new replies.