LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default automatic page break

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro and automatic page break yepidu Excel Discussion (Misc queries) 3 November 3rd 09 09:18 PM
Excel-page break automatic brookse Excel Discussion (Misc queries) 1 June 22nd 09 04:23 PM
Excel: How do you insert an automatic page break after each row? tjw Excel Discussion (Misc queries) 1 January 15th 08 10:21 PM
Cannot move an automatic page break financialsecretary Excel Discussion (Misc queries) 3 July 25th 07 05:06 PM
Can I set an automatic page breaks to break every 40 lines? Kennbu Excel Discussion (Misc queries) 1 June 15th 06 05:59 PM


All times are GMT +1. The time now is 10:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"