Sub 插入分页符()
Dim dyfw As Range
Dim col As Integer
Dim i As Long
Set dyfw = Range("datebase")
col = 2
With ActiveSheet
.PageSetup.PrintTitleRows = dyfw.Resize(1)
.EntireRow.Address
.PageSetup.PrintArea = dyfw.Address
.ResetAllPageBreaks
End With
For i = 2 To dyfw.Rows.Count - 1
If dyfw.Cells(i, col).Value <> dyfw.Cells(i + 1, col).Value Then
dyfw.Cells(i + 1, 1).PageBreak = xlPageBreakManual
End If
Next i
Application.DisplayAlerts = False
ActiveWindow.View = xlPageBreakPreview
frmpagebreak.showvbmodeless
Application.DisplayAlerts = True
End Sub