怎么实现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
广告 您可能关注的内容 |