title: VBA Selecting Columns depending on a cell value
body: <p>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?</p>
  
  <p><img src="https://s18.postimg.org/4d6f544ft/viewoptions.png" alt="view options"></p>
  
  <p><img src="https://s14.postimg.org/y4yiyacgx/viewoptions.png" alt="table"></p>
  
  <p>Here is the code I currently have, but it requires the cells to be defined in the macro code:</p>
  
  <pre><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
  </code></pre>
  
  <p>Any guidance would be much appreciated.</p>