Page Breaks


Posted by karen on December 22, 2000 9:14 AM

I need to insert page breaks at every spot where there are equal signs entered across the cells in a very long spreadsheet. To insert them manually will take forever. Can I use the macro function somehow?

Thank you.

Karen



Posted by cpod on December 22, 2000 5:32 PM


Insert this code to run on a button click:

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

It will seach column A in the used region for any cell with a = except formula cells and enter a page break.