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 quot;J/Jquot; 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(quot;A:Aquot;).Select
rend = Cells(Rows.Count, quot;Aquot;).End(xlUp).Row
For i = 1 To rend
Set fndrng = Selection.Find(what:=quot;amiquot;, 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: www.excelforum.com/member.php...oamp;userid=29540
View this thread: www.excelforum.com/showthread...hreadid=494411
- Jun 04 Wed 2008 20:44
Coding for Page Break
close
全站熱搜
留言列表
發表留言
留言列表

