I have a spreadsheet that is incredibly large hundreds of columns by thousands or rows, I have the ability to check boxes to determine what columns are displayed. The problem is I now want to group the columns based on the value of a cell towards the top of each column (Row 10). This would allow the category to be dynamic and will allow an item to change from one category to another and be either hidden or displayed based on the check box state for that category.
The code that I currently have in the macro to allow the checkbox to toggle between hidden and visible per each team is below. they are currently grouped in groups of 20, I want to eliminate the static grouping of 20 and replace that with the array of columns whose cell on row 10 contains the category (Currently "Team 1" in this example.
Sub Team1()
Set target = Range("B1")
If target.Value = "TRUE" Or target.Value = "True" Then
ActiveSheet.Columns("F:Y").EntireColumn.Hidden = False
ElseIf target.Value = "FALSE" Or target.Value = "False" Then
ActiveSheet.Columns("F:Y").EntireColumn.Hidden = True
End If
End Sub