Copy whole worksheet with keep COLOR format

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I tried to copy selected worksheet to new WorkBook. But during the operation CELLs/COLUMN/ROW COLOR have been changed :/

Code:
For Each ws In wb.Sheets
        next_ws = ws.Name
        
        If dict_sheet.exists(next_ws) Then

            If next_ws = "Sam" Then
                Set NewBook = Workbooks.Add
                ws.Copy Before:=NewBook.Sheets(1)
                    NewBook.Worksheets("Sam").Cells.Select
                    Selection.Copy
                    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                    Range("A1").Select
            Else if....
            etc....
        End if
      End if
Next


Do you know why or how to resolve the issue?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi Forestq,

If your source workbook is using theme colors (a pallet) that is different than the one in your target workbook (or new workbook template), then the displayed colors will change.

You can add a step to load the same pallet in the new workbook.

For example to load the "Office 2007 - 2010" pallet....

Code:
NewBook.Theme.ThemeColorScheme.Load ( _
   "C:\Program Files (x86)\Microsoft Office\Document Themes 15\Theme Colors\Office 2007 - 2010.xml")
 
Upvote 0
thank you Jerry, I tested and it works!

Also, I tried to do as below and orks:
Code:
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

But I need to first copy as paste as value, then above code (but all function will be write), so then once again I need to paste as value.

Your code is much more transparent.
 
Upvote 0

Forum statistics

Threads
1,214,390
Messages
6,119,235
Members
448,879
Latest member
VanGirl

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