Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
jesmin
 
Posts: n/a
Default Coding for Page Break


Hi TheI am generating an excel report. In a single excel sheet, I
have 6 data sets from 6 tables. I want to put only 2 data sets per
page. After this 2 data set, I need a page break at row no3 after the
last data cell in that data area(2nd set data). Each data set has a
common word "J/J" in top line. this I will find(). How ca I give a page
break. I tried this code but not working.
--------
sub pgbreak()
ActiveSheet.ResetAllPageBreaks
Columns("A:A").Select
rend = Cells(Rows.Count, "A").End(xlUp).Row

For i = 1 To rend
Set fndrng = Selection.Find(what:="ami", After:=ActiveCell)
If Not fndrng Is Nothing Then
j = j + 1
Cells(fndrng.Row, 1).Activate
r = ActiveCell.End(xlDown).Row
i = r
If (j = 2) Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=Cells(r + 3, 1)
j = 0
End If
Else
Exit Sub
End If
Next i
End Sub

I am getting an error looping several times. How can I simplify the
code?

Thanks in advance.


--
jesmin
------------------------------------------------------------------------
jesmin's Profile: http://www.excelforum.com/member.php...o&userid=29540
View this thread: http://www.excelforum.com/showthread...hreadid=494411

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
cannot insert page break tsmanz Excel Discussion (Misc queries) 2 December 5th 05 05:45 PM
Can't delete a page break Suhail Excel Discussion (Misc queries) 4 July 7th 05 06:49 PM
Want Excel to break links between worksheets in same file eclectic_kx Excel Worksheet Functions 1 May 25th 05 06:38 PM
shortening a forumula Mike_sharp Excel Discussion (Misc queries) 4 May 4th 05 04:54 PM
content does not stay in page break notexcellent Excel Worksheet Functions 1 February 13th 05 05:55 AM


All times are GMT +1. The time now is 03:11 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"