Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide Columns based on checkbox values
I have a 'main' worksheet which features a series of checkboxes next to
criteria in drop down boxes. They are to show\hide columns on a sheet called "Report" The top line is an "all" which, when selected, marks all 12 boxes as true. Underneath on seperate lines are the 12 other checkboxes. I want to be able to: 1. If "all" is selected, show all columns on "Report" OR 2. Based on the value of each checkbox, show or hide the related column in "Report" I assume that I will have to have code similar to: Private Sub CheckBox2_Click() Worksheets("Report").Activate Columns("B:B").Select Selection.EntireColumn.Hidden = True End Sub Or maybe Private Sub CheckBox2_Click() IF checkbox2 = True Worksheets("Report").Activate Columns("B:B").Select Selection.EntireColumn.Hidden = True END IF End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide Columns based on checkbox values
You don't need to activate the sheet and you don't need to select the column.
This code will act as a toggle for hiding/showing column B in Sheet2. With ThisWorkbook.Sheets("Sheet2").Columns("B") .Hidden = Not .Hidden End With "D Zandveld" wrote: I have a 'main' worksheet which features a series of checkboxes next to criteria in drop down boxes. They are to show\hide columns on a sheet called "Report" The top line is an "all" which, when selected, marks all 12 boxes as true. Underneath on seperate lines are the 12 other checkboxes. I want to be able to: 1. If "all" is selected, show all columns on "Report" OR 2. Based on the value of each checkbox, show or hide the related column in "Report" I assume that I will have to have code similar to: Private Sub CheckBox2_Click() Worksheets("Report").Activate Columns("B:B").Select Selection.EntireColumn.Hidden = True End Sub Or maybe Private Sub CheckBox2_Click() IF checkbox2 = True Worksheets("Report").Activate Columns("B:B").Select Selection.EntireColumn.Hidden = True END IF End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Hide Columns based on a cell value | Excel Worksheet Functions | |||
Checkbox to Hide/Unhide Columns Based on Value in Cell | Excel Programming | |||
Hide Columns Based on Condition | Excel Programming | |||
Hide / Unhide Columns with checkbox | Excel Programming | |||
Hide a row based on values | Excel Programming |