« Check to see if file exists before opening: VBA Excel | Main | Remove pagebreaks: VBA Excel »
Sunday
Jul152007

Automatically add pagebreaks at interval: VBA Excel

Dim intCntRows As Integer
Dim intLastRow As Integer
intLastRow = ActiveSheet.UsedRange.End(xlDown).Row
intCntRows = 2
Do Until intCntRows = intLastRow
If InStr(ActiveSheet.Cells(intCntRows, 1), "=") > 0 And Range("A" & intCntRows).HasFormula = False Then
ActiveSheet.Rows(intCntRows + 1).PageBreak = xlPageBreakManual
End If
intCntRows = intCntRows + 1
Loop

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Textile formatting is allowed.