All,
I have a workbook that has TRUE or FALSE values in row 4. These true or false cells are linked to checkboxes in row 3 above. There are two distinct functions that I'm trying to achieve.
1.) I'm trying to create code that hides each column with a FALSE value in row 4 (hiding all columns with unchecked boxes). Another complexity is that it needs to hide the checkbox as well so that there aren't a bunch of rogue checkboxes after the columns are hidden. It also needs to be dynamic as columns are added and deleted. My work in process code is:
2.) I also want to create another set of code that will uncheck all boxes in row 2, unhide all columns, and unhide all checkboxes thus returning everything to it's original form. I've tried to do this by changing all values in row 4 to false which unchecks the box.
Thanks in advance!
I have a workbook that has TRUE or FALSE values in row 4. These true or false cells are linked to checkboxes in row 3 above. There are two distinct functions that I'm trying to achieve.
1.) I'm trying to create code that hides each column with a FALSE value in row 4 (hiding all columns with unchecked boxes). Another complexity is that it needs to hide the checkbox as well so that there aren't a bunch of rogue checkboxes after the columns are hidden. It also needs to be dynamic as columns are added and deleted. My work in process code is:
Code:
Sub HideColumns()
Dim xRange As Range
Set xRange = Cells(4, 2).End(xlToRight)
Set xRange = Range(Range("b4"), xRange)
With xRange
If Cells.Value = "FALSE" Then
Columns.EntireColumn.Hidden
End With
End Sub
2.) I also want to create another set of code that will uncheck all boxes in row 2, unhide all columns, and unhide all checkboxes thus returning everything to it's original form. I've tried to do this by changing all values in row 4 to false which unchecks the box.
Code:
Sub UncheckAllBoxes()
'uncheck boxes
Dim xRange As Range
Set xRange = Cells(4, 2).End(xlToRight)
Set xRange = Range(Range("b4"), xRange)
With xRange
If Cells.Value = "TRUE" Then Cells.Value = "FALSE"
End With
'unhide all columns
Columns.EntireColumn.Hidden = False
'uncheck all checkboxes???
End Sub
Thanks in advance!