title: How to use an array to find excel columns and move the found columns to another worksheet
body: <p>I have an array of column headers in an order that I need them to be.
  I want to use this array to find column headers in an excel worksheet and copy the columns to a new worksheet. One or more of the columns might not exist in the worksheet, so I would like for it to skip that column if it is not found.</p>
  <p>Here is what I have so far which works fine if all of the columns are always in the worksheet, however if a column doesn't exist it does not work.</p>
  <pre><code>    Option Explicit
  
  Sub MoveCol2() 'Excel VBA to move Columns based on criteria
  Dim ar As Variant
  Dim i As Integer
  Dim j As Long
  
  'Set the Array Values
  ar=Array(&quot;Sales&quot;, &quot;Dept 1&quot;, &quot;Dept 8&quot;, &quot;Dept 9&quot;)
  
  For i=0 To UBound(ar) 'Loop through the Array
  j=[A1:S1].Find(ar(i)).Column
  Columns(j).Copy Sheet2.Cells(1, i + 1) 'Add 1 at end as array starts at 0
  Next i
  End Sub
  </code></pre>
  <p>Long story short, the goal here is if the column header isn't in the worksheet, then don't throw an error and move on to the next column header in the array.</p>
  <p>As always, thank you all in advance for any help you can provide.</p>