Excel/Excel Page Break Question
Expert: Tom Ogilvy - 7/10/2009
QuestionHi Tom,
This seems like it should be a very simple problem but for some reason it is not working. I have a report that I am hoping to automate page breaks on. Every time the cell in column "S" says "1. det act vs pl" I want to put a page break right above it.
This is the code I've come up with so far. Any suggestions?
Thank you so much for your help!
Best,
Sarah
Sub pagebrk()
col = 11
LastRw = 590
For x = 1 To LastRw
If cell = "1. det act vs pl" Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Rows(x)
End If
Next
End Sub
AnswerSarah,
Try it this way:
Sub pagebrk()
col = 11
LastRw = 590
For x = 1 To LastRw
If Cells(x, col).Value = "1. det act vs pl" Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Rows(x)
End If
Next
End Sub
change col to reflect the column that contains the text your searching for.
--
Regards,
Tom Ogilvy
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your
Excel question answered in this area then please ask an Excel question here