Hello,
I have 3 ActiveX Check Boxes named "Red," "Green," and "Blue" that will unhide and hide columns when the value in a row meets the criteria identified in the code. When 1 box is checked and unchecked, the result is good (check the box and the correct columns are unhidden, uncheck the box and the columns are hidden again).
I would also like the option of checking multiple boxes to display different column combinations. For example: Check both "Red" and "Blue" displays both red and blue columns. Unckeck "Blue" and red columns remain displayed.
Problem: when I check more than 1 box, the columns that were revealed with the first check box become hidden again.
Here is a sample of the code I'm using... I'm new to VBA...thank you for your help!
I have 3 ActiveX Check Boxes named "Red," "Green," and "Blue" that will unhide and hide columns when the value in a row meets the criteria identified in the code. When 1 box is checked and unchecked, the result is good (check the box and the correct columns are unhidden, uncheck the box and the columns are hidden again).
I would also like the option of checking multiple boxes to display different column combinations. For example: Check both "Red" and "Blue" displays both red and blue columns. Unckeck "Blue" and red columns remain displayed.
Problem: when I check more than 1 box, the columns that were revealed with the first check box become hidden again.
Here is a sample of the code I'm using... I'm new to VBA...thank you for your help!
Code:
Private Sub CheckBox1_Click()
'
' CheckBox1 Macro: Unhides all columns with the Word "Red" in row 11.
'
BeginColumn = 8
EndColumn = 16
ChkRow = 11
Application.ScreenUpdating = False
For ColCnt = BeginColumn To EndColumn
If CheckBox1.Value = True And Cells(ChkRow, ColCnt).Value = "Red" Then
Cells(ChkRow, ColCnt).EntireColumn.Hidden = False
Else
Cells(ChkRow, ColCnt).EntireColumn.Hidden = True
End If
Next ColCnt
End Sub