title: Copy an array of sheets using a variable Sheets(Array(Variable)).Copy
body: <p>I'm having real trouble creating a string to use as the variable to copy differing tabs each time it's run depending on which cells are ticked.</p>
  <p>My code cycles through a row of cells and anything with a tick (P) then adds to the array string.
  The text generated in the string is identical to the hard coded equivalent but I get a runtime error 9 when I try to copy the tabs using the string.
  The &quot;rw&quot; is populated in a previous macro that call this one.</p>
  <p>My code is</p>
  <pre><code>public rw, col  as long
  public add      as string
  public add1     as variable
  
  sub create_pack
  
      Application.DisplayAlerts = False
  
      Set wb1 = ActiveWorkbook
      
      col1 = 8
      add = &quot;&quot;
      Do Until col1 &gt; 17
          If sh00.Cells(rw, col1) = &quot;P&quot; Then
              If add = &quot;&quot; Then
                  add = &quot;&quot;&quot;Pack &quot; &amp; col1 - 7 &amp; &quot;&quot;&quot;&quot;
              Else
                  add = add &amp; &quot;, &quot;&quot;Pack &quot; &amp; col1 - 7 &amp; &quot;&quot;&quot;&quot;
              End If
          End If
          col1 = col1 + 1
      Loop
  
      add1 = Array(add)
      wb1.Sheets(add1).Copy
      Set wb2 = ActiveWorkbook
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7Bnal.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Bnal.png" alt="enter image description here" /></a></p>
  <p>Any help gratefully received as I'm completely stumped on this one.
  Thank you.</p>