title: VBA: Make copy of workbook, remove shets and then save it with different name?
body: <p>I am trying to do the following:</p>
  
  <ul>
  <li>Copy a workbook</li>
  <li>Remove some of the sheets</li>
  <li>Save it as a different file name</li>
  </ul>
  
  <p>This was my attempt but its not working:</p>
  
  <pre><code>Private Sub publish()
      Dim new_wb As Workbook
  
      'Doesnt seem to compile??
      Set new_wb = ActiveWorkbook.Sheets.Copy
  
      For i = new_wb.Sheets.Count To 1
          If InStr(LCase(new_wb.Sheets(i).CodeName), "output") = 0 Then
              new_wb.Sheets(i).Delete
          End If
          i = i - 1
      Next
  
      Application.DisplayAlerts = False
      new_wb.SaveCopyAs Filename:=Range("output_path").Value
      new_wb.Close
      Application.DisplayAlerts = True
  
  End Sub
  </code></pre>
  
  <p>Could someone please help me where I am going wrong?</p>