#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 14
Default Format Page breaks

That works great! I am trying to format the borbers to appear around each
cell but I can't get it to limit the formatting to cells with value. I don't
want to format more cells than I need to beacuse I'll end printing a bunch of
pages of empty boxes.

Can the "Dim" command be used for that?

"Rick Rothstein" wrote:

Give this macro a try (change the worksheet name reference to the worksheet
name you want to apply this code to)...

Sub AddPageBreaks()
Dim X As Long
Dim LastRow As Long
With Worksheets("Sheet1")
.Cells.PageBreak = xlPageBreakNone
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
For X = 2 To LastRow
If .Cells(X - 1, "B").Value < .Cells(X, "B").Value Then
.Rows(X).PageBreak = xlPageBreakManual
End If
Next
.Rows(LastRow + 1).PageBreak = xlPageBreakManual
End With
End Sub

--
Rick (MVP - Excel)


"Matt G" wrote in message
...
Hi,

I'm trying to write a macro that will sort sheet by a particular column
"B"
and then llok through that column and set a page break whenever the value
of
any row in comumn "B" changes.

For example:
A B C
1 r t g
---------------------- Page Break
2 d u w
3 s u e
---------------------- Page Break
4 e v d

Any Ideas?

Thanks in advance



Reply
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
I can't move my page breaks in Page Break Preview btaft Excel Discussion (Misc queries) 6 April 27th 23 11:49 AM
Different Page Numbers In Worksheet w/Page Breaks UT Excel Discussion (Misc queries) 8 January 16th 09 06:48 PM
moving page breaks and document format Luke Williams Excel Discussion (Misc queries) 0 March 5th 08 03:19 PM
How do I do page breaks when view menu doesnt page break preview HeatherF55 Excel Discussion (Misc queries) 0 September 21st 07 04:24 AM
Page Breaks- Printing selected rows on same page ToddEZ Excel Discussion (Misc queries) 1 July 18th 07 04:38 PM


All times are GMT +1. The time now is 01:15 PM.

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"