Range problem in quickie Pagebreak code

Mr. Guy

New Member
Joined
Mar 24, 2002
Messages
18
Hi
I'm having a problem with a little piece of vba that I'm using. Basically what I want this to do is insert a page break every 37 rows starting at row 48 and ending at row 2138. What happens is it starts at row 37 and then adds a pagebreak every 37 rows, ignoring the starting range I set for it (A48) but still completing at my finishing range (A2138). I've tried changing the start range to numberous values but cannot seem to find any reason to it.

Sub AddPageBreak()
interval = 37
For Each Cell In Range("A48:A2138")
n = n + 1
If n Mod (interval + 1) = 0 Then
Worksheets("Tech").Rows(n).PageBreak = xlPageBreakManual
End If
Next Cell
End Sub

Any suggestions??
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top