怎么实现EXCEL表格 批量插入分页符 进行分页打印呢?
Sub crfyf()
Dim i&, j&粗薯, r&
For i = 2 To Cells(Rows.Count, 1).End(3).Row
Cells(r + 1, 7) = [a1]
Cells(r + 1, 8) = Cells(i, 1)
r = r + 1
For j = 2 To 5
If Cells(i, j) <塌核> "" Then
Cells(r + 1, 7) = Cells(1, j)
Cells(r + 1, 8) = Cells(i, j)
r = r + 1
End If
Next
Next
ActiveSheet.PageSetup.PrintArea = "$G$1:$H$" & r
For i = 2 To r
If Cells(i, 7) = [a1] Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i, 7)
End If
Next
With Range("团凳掘$G$1:$H$" & r)
.Borders(xlInsideVertical).LineStyle = xlContinuous '
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
.HorizontalAlignment = xlCenter
End With
End Sub