Printable area check.

backup69

Active Member
Joined
Jan 20, 2004
Messages
271
Hi all

Is there any command in VBA that enables me to see if the printable sheet fits in width on the first paper with all its columns (Compare usedrange columns with first page columns)? After setting the printable area i would like to know how many columns don not fit on the page, with that information i could decide weather to use FitToPagesWide method or change Left and RightMargins before that.

ty
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Code:
Sub PageBreakColumn()
Dim LC As Long, FB As Long
LC = Range([A1], ActiveSheet.UsedRange).Columns.Count
Application.ScreenUpdating = False
On Error GoTo e
ActiveWindow.View = xlPageBreakPreview
FB = ActiveSheet.VPageBreaks(1).Location.Column
If FB <= LC Then
    MsgBox "Columns after column " & FB - 1 & " (up to column " & LC & ") do not fit on one page."
    ActiveWindow.View = xlNormalView
Else
e: MsgBox "All columns fit on one page."
End If
ActiveWindow.View = xlNormalView
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,659
Messages
6,126,074
Members
449,286
Latest member
Lantern

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