Define a range of rows to search for automatic page break

djclifton

New Member
Joined
Jul 26, 2016
Messages
13
I am fairly new to Macros and have a problem that I think can be easily solved but need some experience to help.

The task: 1. Search a range of rows to determine if an automatic page break occurs. 2. If yes, place a manual page break at before the first row in the range. 3. Repeat task for other ranges or groups of rows.

I have written code that works but is fairly long and is going to take me along time to write considering that amount of groups of rows that I have. The code for 1 group looks like this;

Code:
If Rows(54).PageBreak = xlPageBreakAutomatic Or Rows(55).PageBreak = xlPageBreakAutomatic Or Rows(56).PageBreak = xlPageBreakAutomatic Then
Rows(53).PageBreak = xlPageBreakManual
End If

I have tried to rewrite the code like this but it only searches the first row in the range (in this case row 54);

Code:
If Rows("54:56").PageBreak = xlPageBreakAutomatic Then
'Rows(53).PageBreak = xlPageBreakManual
End If

Can any one tell me what I am doing wrong?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,022
Messages
6,175,972
Members
452,691
Latest member
Tony_Almeida

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