Print fixed range in portrait/Landscape

Posted on 2013-01-14
Last Modified: 2013-01-14
I have a set range
B5:AE102  Need a button to print it in portrait and another button to print in Landscape

how do i do this with VBA?
Question by:ansonindustries
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 13

Expert Comment

ID: 38775429
sub PortPrint
                  ActiveSheet.PageSetup.Orientation = xlPortrait
                    ActiveSheet.PageSetup.PrintArea = "$B5:AE102"
end sub

Open in new window

sub landscapePrint
                    ActiveSheet.PageSetup.Orientation = xlLandscape
                    ActiveSheet.PageSetup.PrintArea = "$B5:AE102"

end sub

Open in new window

Assign these macros to buttons as preferred

Author Comment

ID: 38775725
this works great however i notice that it prints automatically.  Is there a way to have the print setup box open up where the user can select a printer and then print?
LVL 13

Accepted Solution

Shanan212 earned 500 total points
ID: 38775765
instead of


^ delete that line and insert this on both sets of code


Author Closing Comment

ID: 38775819
works great! thanks your awesome!
LVL 13

Expert Comment

ID: 38776019
Glad that helped :)

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question