title: Excel Vba - Calling a sheet with a variable sheet name
body: <p>I've been coding in VBA for some time, but this one has really stumped me.</p>
  
  <p>I'm creating a workbook which creates technical certificates for machines. We have varying templates depending on the machine type and I am attempting to get my code to select the correct sheet from a user input and then populate the sheet. FYI these template sheets will be hidden and the user can only interact with the userforms.</p>
  
  <p>Heres the code that is failing:</p>
  
  <pre><code>Machine = MachineType.Text '&lt;-- input from userform, for example Machine = "Vertex 251"
  
  Set wsCopy = ThisWorkbook.Sheets(Machine) '&lt;--- select that machine's sheet
  wsCopy.Copy '&lt;--Run time Error 1004: Method copy of object_worksheet failed
  </code></pre>
  
  <p>I've tried numerous different types including just <code>sheets(machine).copy</code> or </p>
  
  <pre><code>Sheets(machine).activate
  Activesheet.copy
  </code></pre>
  
  <p>but nothing has worked so far - I cannot tell if I am doing something fundamentally wrong.</p>
  
  <p>Any help would be be appreciated.</p>
  
  <p>Cheers.</p>