I am trying to make view options in an Excel table. I have the radio buttons ready, marked Sales, Contracts, Accounts and All. Each one will show/hide columns depending on which ones are relevant to the particular department. The way I want to filter which columns are relevant is by having a cell in each column (at the top) which checks if it contains s,c or a. Is the best way to use commas if two departments need to view the same column?
Here is the code I currently have, but it requires the cells to be defined in the macro code:
Sub SalesOption_Click()
Columns("B:DD").Select
Selection.EntireColumn.Hidden = True
Application.Union(Columns("c:p"), Columns("bt:bw"), Columns("cb")).Select
Selection.EntireColumn.Hidden = False
Range("$A$1").Select
End Sub
Sub AllOption_Click()
Columns("B:DD").Select
Selection.EntireColumn.Hidden = False
Range("$A$1").Select
End Sub
Any guidance would be much appreciated.