PDA

View Full Version : If row 55 is not on page 1, then keep reducing the bottom margin by 0.1



uktous
04-06-2013, 05:54 AM
Hi,

Could you please write a macro which can perform the following actions?

If row 55 is not on page 1, then keep reducing the bottom margin by 0.1, until row 55 is on page 1.

Thanks

mdmackillop
04-06-2013, 07:28 AM
Sub Macro2()
Dim i As Long, y As Long

y = ActiveSheet.Rows(56).PageBreak
If y = -4142 Then
With ActiveSheet.PageSetup
Do
.BottomMargin = .BottomMargin - 0.1
i = ActiveSheet.Rows(56).PageBreak
If i <> y Then Exit Do
Loop Until .BottomMargin < 5
End With
End If
End Sub