Hello, I am using the following code (which works great) to export the sheets named "Labor BOE xxxx" after my spreadsheet creates multiple copies of a template worksheet, inserts summary tables, and populates the summary tables. The one issue that I haven't been able to figure out is... after these worksheets have been copied into the new workbook... the cell color/fill changes.
Does anyone have an idea on how to prevent this from happening? Also... is it possible to modify this code so it deletes the sheets beginning with "Labor BOE" from my original worksheet?
Does anyone have an idea on how to prevent this from happening? Also... is it possible to modify this code so it deletes the sheets beginning with "Labor BOE" from my original worksheet?
Code:
Sub Export_BOE()
Dim Sh As Worksheet, wb As Workbook, txt As String
Set wb = Workbooks.Add
On Error Resume Next
For Each Sh In ThisWorkbook.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 BOE Version Number or Date", "BOE Export")
wb.SaveAs ThisWorkbook.Sheets("Home").Range("$F$9").Value & "_" & txt & ".xlsx"
MsgBox "BOE generation is complete." & Chr(10) & Chr(10) & "Required Steps:" & Chr(10) & Chr(10) & "1. Review the BOE Export file for anomolies." & Chr(10) & Chr(10) & "2. Verify that all required fields have been populated."
End Sub
Last edited: