Export values to another workbook - problem with color theme

neodjandre

Well-known Member
Joined
Nov 29, 2006
Messages
950
Office Version
  1. 2019
Platform
  1. Windows
Hey all,

I am using this code to export values to a new workbook. However, the new workbook automatically uses a different color theme for sheets and cell coloring compared to my original workbook.

VBA Code:
Sub export_values()
Dim sourceWB As Workbook
Dim destWB As Workbook
Dim ws As Worksheet
Dim path As String
Dim fname As String
Dim sh As Worksheet
Dim i As Integer
Dim shp As Shape
Dim e_comp As String
Dim lastRow As Long
Dim er As Long

e_comp = ThisWorkbook.Names("i_co").RefersToRange(1, 1)

path = ThisWorkbook.path & "\"
fname = e_comp & "_values_" & Format(Now, "dd_mmm_yy_hh_mm_ss")
fname = clean_filename(fname, "")

Set sourceWB = ThisWorkbook

Set destWB = Workbooks.Add
destWB.SaveAs path & fname, FileFormat:=xlExcel12
   
For Each ws In sourceWB.Worksheets

If CLng(ws.Range("B1").value) = "2" Then
i = i + 1
ws.Copy After:=destWB.Sheets(destWB.Sheets.Count)
End If
       
Application.StatusBar = "Processing..." & ws.Name
Next ws

For Each sh In destWB.Worksheets

sh.Activate

With sh.UsedRange
.value = .value
End With
   
Application.StatusBar = "Converting..." & sh.Name
Next sh

destWB.Save

End Sub

How could I retain my original color theme? Any help would be much appreciated.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

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
Back
Top