![]() |
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 |
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 |
All times are GMT +1. The time now is 05:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com