excel 根据内容自动插入分页符

Sub FY_AD()

Dim rng As Range

‘从4行至25行进行分面操作;

For Each rng In Range(“A2:A25”)

‘以“newpage”作为分页条件,在A列中的第4行至25行如果有1则在该处插入打印分页符

If rng.Value = “newpage” Then

‘插入分页符

ActiveSheet.HPageBreaks.Add rng

End If

Next

End Sub