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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,883
Messages
5,766,911
Members
425,385
Latest member
djkevnic

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
Top