Skip to content

Instantly share code, notes, and snippets.

@zhimiaoli
Created November 26, 2013 10:39
Show Gist options
  • Save zhimiaoli/7656368 to your computer and use it in GitHub Desktop.
Save zhimiaoli/7656368 to your computer and use it in GitHub Desktop.
根据单元格内容自动创建分页符
Sub createPageBreak()
'创建分页
'在小计后面添加手动分页
For i = 1 To 10000 '只到10000行
If Cells(i, 1) = "小计" Then '设置分行内容
Cells(i, 1).Select
ActiveCell.Offset(1, 1).Rows("1:1").EntireRow.Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
End If
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment