Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The only time I've seen this kind of line:
If InStr(1, Cells(x, 1), "Total") 0 Then cause an error is when there's an error in that cell. I'd try: If InStr(1, Cells(x, 1).Text, "Total") 0 Then I've seen it when x isn't a valid row number, but that doesn't look like the problem here. Randy wrote: Why won't the following macro work to create a page break - in particular it is giving me an error at the InStr line Sub b8Pagebrk() Dim theRange As Range Dim lastrow&, firstRow&, x& Set theRange = ActiveSheet.UsedRange lastrow = theRange.Cells(theRange.Cells.Count).Row firstRow = theRange.Cells(1).Row For x = lastrow To firstRow Step -1 If InStr(1, Cells(x, 1), "Total") 0 Then Cells(x + 1, 1).PageBreak = xlManual End If Next End Sub -- Randy -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro and automatic page break | Excel Discussion (Misc queries) | |||
Excel-page break automatic | Excel Discussion (Misc queries) | |||
Excel: How do you insert an automatic page break after each row? | Excel Discussion (Misc queries) | |||
Cannot move an automatic page break | Excel Discussion (Misc queries) | |||
Can I set an automatic page breaks to break every 40 lines? | Excel Discussion (Misc queries) |