VBA Copy and Paste Formatting for all Worksheet

ilhamideaz

New Member
Joined
May 27, 2021
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I try to write really simple script to copy original worksheet (ORIGINAL_NOCHANGE) and paste the formatting only other sheet.
In the ORIGINAL_NOCHANGE, there are some column merged together, and some column having the conditional formatting.

This is the original structure of ORIGINAL_NOCHANGE :
1622126459068.png


COPY1 and COPY2 are the copy of ORIGINAL_NOCHANGE, but has no format like the original one (my Python script cannot copy the Excel formatting).

After I run my VBA script :

VBA Code:
Sub TrySecond()

Dim ws As Worksheet

'Worksheets("ORIGINAL_NOCHANGE").Activate
Worksheets("ORIGINAL_NOCHANGE").Range("A1:AA71").Copy

For Each ws In Worksheets
    If ws.Name <> "ORIGINAL_NOCHANGE" Then
            'ws.Range("AC1") = "Are You Kidding Me"
            Range("A1:P17").Select
            Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    End If
Next
End Sub

the ORIGINAL_NOCHANGE has been changed into this structure, which I really don't want :

1622126715078.png


but nothing happend in COPY1 and COPY2!

Note that my python script will copy hundreds of ORIGINAL_NOCHANGE worksheet but due to the limitation of package inside, it couldn't copy the formatting.
Putting here as somebody might be suggesting me to copy the original manually.

I'm not sure what's the mistake in my script. Can you please help?

Thanks a lot!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try this
VBA Code:
Sub TrySecond()

Dim ws As Worksheet

For Each ws In Worksheets
    If ws.Name <> "ORIGINAL_NOCHANGE" Then
            Sheets("ORIGINAL_NOCHANGE").Cells.Copy ws.Range("A1")
    End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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