Alt+L+V调出VBA界面
alt+F11也可以调出VBA界面
插入-模块
比如操作100行的数据
Sub 总的()
Sheets("sheet1").Copy after:=Sheets(Sheets.Count)
'先分别插入两行
For i = 3 To 100 Step 3
Range("A" & i).Select
Selection.EntireRow.Insert
Selection.EntireRow.Insert
Next
'接着加入很多相同的表头
For i = 4 To 100 Step 3
Range("A1:L1").Select
Selection.Copy
Range("A" & i).Select
ActiveSheet.Paste
Next
'最后合并一行单元格并改变单元格的字体和颜色
For i = 3 To 100 Step 3
Range(Cells(i, 1), Cells(i, 8)).Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.Font.Bold = True
Selection.Font.Size = 12
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
Next
End Sub