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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Boller

Banned
Joined
Apr 11, 2006
Messages
2,328
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
 

Forum statistics

Threads
1,144,517
Messages
5,724,817
Members
422,580
Latest member
ScotIain76

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