您可以使用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
一个Excel文件的工作簿。工作簿可以包含多个工作表。这工作你希望有更新的格式吗?如果你在上面添加一个空行,第1行是空的。为什么你是否将它设置为粗体?你如何知道每天要更新哪些工作簿?我认为在你尝试创建代码以满足这个要求之前,你需要考虑稳固的需求。 –
@Bob Moshon尝试下面的代码,它将格式化一张表。 –