Good morning,
I found and adapted this macro to take the formatting from one tab and apply it to any existing tabs. I want to place this in a separate workbook, instead of having to add it into every workbook I apply it to. I can't figure out what to update. Could you please help me to update this macro to apply to the active workbook and all tabs, as opposed to the workbook it resides in?
Thank you so much!
I found and adapted this macro to take the formatting from one tab and apply it to any existing tabs. I want to place this in a separate workbook, instead of having to add it into every workbook I apply it to. I can't figure out what to update. Could you please help me to update this macro to apply to the active workbook and all tabs, as opposed to the workbook it resides in?
Thank you so much!
Code:
Sub Wsh_PasteSpecial_Test()
Dim aWshExcluded As Variant, vWshExc As Variant
aWshExcluded = Array("Exclude(1)", "Exclude(2)")
Dim WshSrc As Worksheet
Dim WshTrg As Worksheet
Rem Set Source Worksheet
Set WshSrc = ThisWorkbook.ActiveSheet
Application.ScreenUpdating = 0
Rem Process All Worksheets
For Each WshTrg In WshSrc.Parent.Worksheets
Rem Exclude Worksheet Source
If WshTrg.Name <> WshSrc.Name Then
Rem Validate Worksheet vs Exclusion List
For Each vWshExc In aWshExcluded
If WshTrg.Name = vWshExc Then GoTo NEXT_WshTrg
Next
Rem Process Worksheet Target
With WshTrg.Cells
WshSrc.Cells.Copy
.PasteSpecial Paste:=xlPasteFormats 'Source format is pasted.
.PasteSpecial Paste:=xlPasteComments 'Comments are pasted.
.PasteSpecial Paste:=xlPasteValidation 'Validations are pasted.
Application.CutCopyMode = False
Application.Goto .Cells(1), 1
End With: End If:
NEXT_WshTrg:
Next
Application.Goto WshSrc.Cells(1), 1
Application.ScreenUpdating = 1
End Sub