Hello, I am using the following code to copy multiple worksheets into a new workbook. Unfortunately, the worksheets aren't copying over. I am wondering if creating the new workbook is changing my "Activeworkbook" which is referenced on line 6. Any thoughts on how to correct this?
Also, I am hoping to delete these worksheets from my initial workbook after they have been copied into the new worksheet.
Also, I am hoping to delete these worksheets from my initial workbook after they have been copied into the new worksheet.
Code:
Sub Export_BOE_Sheets()
Dim Sh As Worksheet, wb As Workbook, txt As String
Set wb = Workbooks.Add
wb.Sheets(1).Name = "BOE Cover Sheet"
On Error Resume Next
For Each Sh In ActiveWorkbook.Sheets
If Left(Sh.Name, 9) = "Labor BOE" Then
Sh.Copy After:=wb.Sheets(wb.Sheets.Count)
End If
Next Sh
On Error GoTo 0
txt = InputBox("Enter the Date and/or Version number", "BASIS OF ESTIMATES")
wb.SaveAs ThisWorkbook.Sheets("Home").Range("$F$9").Value & "_" & txt & ".xlsx"
MsgBox "The BOE Export file generation is complete."
End Sub
Last edited: