Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 191
Default Inserting A row & page break

Hello

I have data set up like this:

brand POLTRM devmth _NAME_ _2003 _2004 _2005
AD 10 1 bincear 21.8% 18.0% 22.6%
AD 10 2 bincear 16.7% 21.0% 14.6%
AD 10 3 bincear 16.8% 23.9% 14.3%
AD 10 4 bincear 18.5% 23.1% 15.1%
AD 10 5 bincear 19.4% 22.9% 17.7%
AD 12 1 bincear 19.9% 24.3% 18.7%
AD 12 2 bincear 20.4% 22.7% 18.3%
AD 12 3 bincear 19.8% 22.4% 18.3%
AD 12 4 bincear 19.4% 21.8% 18.3%
AD 12 5 bincear 19.6% 21.1% 19.7%

I am trying to set up a macro whereby each time the devmth column drops back
to 1 or is lower than the previous row I would like to insert 5 blank rows
and a page break. I have not had any luck with this at all yet. Can anyone
help.

I would be extremely grateful for any assistance.

Thanks in advance

Jamie


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Inserting A row & page break

Assume the devmth column is column C:

Sub CCC()
Dim lastRow as Long, i as Long
lastrow = cells(rows.count,"C").End(xlup).row
for i = lastrow to 2 step -1
if cells(i,3) < cells(i-1,3) or cells(i,3) = 1 then
cells(i,3).EntireRow.Resize(5).Insert shift:=xlShiftDown
' pagebreak below the 5 blank rows?
Activsheet.HPageBreaks.Add Befo=Rows(i+5)
end if
Next
end Sub

to put the pagebreak at the top of the blank rows, change rows(i+5) to rows(i)

--
Regards,
Tom Ogilvy



"Jamie" wrote:

Hello

I have data set up like this:

brand POLTRM devmth _NAME_ _2003 _2004 _2005
AD 10 1 bincear 21.8% 18.0% 22.6%
AD 10 2 bincear 16.7% 21.0% 14.6%
AD 10 3 bincear 16.8% 23.9% 14.3%
AD 10 4 bincear 18.5% 23.1% 15.1%
AD 10 5 bincear 19.4% 22.9% 17.7%
AD 12 1 bincear 19.9% 24.3% 18.7%
AD 12 2 bincear 20.4% 22.7% 18.3%
AD 12 3 bincear 19.8% 22.4% 18.3%
AD 12 4 bincear 19.4% 21.8% 18.3%
AD 12 5 bincear 19.6% 21.1% 19.7%

I am trying to set up a macro whereby each time the devmth column drops back
to 1 or is lower than the previous row I would like to insert 5 blank rows
and a page break. I have not had any luck with this at all yet. Can anyone
help.

I would be extremely grateful for any assistance.

Thanks in advance

Jamie


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
INSERTING ROWS IMMEDIATELY AFTER PAGE BREAK YESHWANT JOSHI[_2_] Excel Discussion (Misc queries) 0 July 23rd 09 07:35 PM
Inserting page break da Excel Discussion (Misc queries) 3 May 29th 09 10:37 PM
Inserting header @ page break Esrei Excel Discussion (Misc queries) 1 August 12th 05 01:36 PM
Keyboard Shortcut for Inserting a Page Break Tandy Excel Discussion (Misc queries) 6 July 12th 05 09:35 PM
Inserting rows before page break Robert Christie[_3_] Excel Programming 5 December 15th 03 05:24 AM


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

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

About Us

"It's about Microsoft Excel"