Worksheets copied into new workbook - Cell Color/Fill Changes - Unintentional - Preserve Cell Color/Fill

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
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?


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:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Watch MrExcel Video

Forum statistics

Threads
1,132,939
Messages
5,656,041
Members
418,265
Latest member
ferdinandvs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top