EXCEL,将样式表应用于不同的excel文件

目前我有一份工作(哪一项任务)只涉及简单地应用不同的Excel文件相同的风格,相同的格式。

我想找出简化它的方法。

这个样式表(或者某种想法)将需要。

1) Add empty line to very top of the excel file 2) A1-F2 make bold 3) A1-F3 Make full borders 4) A1-F3 Auto Fit Column Width 5) A2-F2 Make colour GREY 

我需要每天将相同的风格应用于大量的文件。 期待着简单的解决scheme。

您可以使用MACRO编码器开始。

无论如何,请尝试下面的代码(它将格式化为“Sheet1”(修改为您请求的工作表名称)。

如果要将其应用于所有表格,则需要遍历工作簿中的所有工作表。

 Option Explicit Sub ApplyExcelShtFormat() Dim Sht As Worksheet ' change Sheet name to your needs Set Sht = ThisWorkbook.Sheets("Sheet1") With Sht ' add 1 Row above the first row .Rows("1:1").Insert Shift:=xlDown ' modify font to bold .Range("A1:F2").Font.Bold = True ' add borders all around .Range("A1:F3").BorderAround xlContinuous, xlThin ' add internal borders With .Range("A1:F3").Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin End With With .Range("A1:F3").Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin End With ' columns auto fit .Range("A1:F3").EntireColumn.AutoFit ' cell interior color grey (change number according to your kind of gray) .Range("A2:F2").Interior.Color = 9868950 End With End Sub 
Interesting Posts