title: VBA Code to Deselect Particular Item from filter OR Swap to solve
body: <p>I have a column called Color, and it is filtered, so I can select\deselect desired Colors.</p>
  
  <p>I recorded a macro to find out how to filter the column for all colors except Blue, Green, and Orange.</p>
  
  <p>The only color that was left was red.</p>
  
  <p>The macro created was as follows:</p>
  
  <pre><code>ActiveSheet.Range("$A$1:$B$5").AutoFilter Field:=1, Criteria1:="Red"
  </code></pre>
  
  <p>The problem with this code is that it will not work for a generic case, because it is including "Red" and excluding everything else, whereas what I need is to exclude Blue, Green, and Orange, and include everything else.</p>
  
  <p>The reason I need a different code is that my color choices can change based on what I get from the database.</p>
  
  <p>For example, if I pull data and create filter automatically, I could have the color Pink in my list, by my code would be broken, because Pink would not be selected, only Red would be selected.</p>
  
  <p>Any tips on fixing this problem?
  One idea would be to select everything that is un-selected, and de-select everything that is selected (if there is any vba code to do that).  With this strategy, I would select Blue, Green, and Orange, then I would run the swap code.</p>