Solved

print only highlighted area

Posted on 2014-04-27
13
62 Views
Last Modified: 2014-11-03
i am looking for two macros one that will print only the highlighted area and one that will print the entire  area.thanks
PRINT-ONLY.xlsb
0
Comment
Question by:Svgmassive
  • 4
  • 3
  • 2
  • +2
13 Comments
 
LVL 68

Expert Comment

by:Qlemo
ID: 40025667
You should be able to record two macros for that purpose, each selecting the areas to print and then call the printing menu. This always gives you a  good start for writing VBA code. Usually you have to cleanup and improve the code somwhat.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40025671
This sets the Printable Area to the highlighted cells:
Worksheets("Sheet1").PageSetup.PrintArea = Union("$C$1:$P$19", "$C$38:$P$51")

Open in new window


This will set the Printable Area to the entire bordered area:
Worksheets("Sheet1").PageSetup.PrintArea = "$C$1:$P$51"

Open in new window


If the highlighted and bordered ranges are dynamic, you will have to loop thru the range testing for the conditions and when met add them to the .PrintArea using the Union function.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40025679
The above code only sets the print area (as the name says). You will still have to call the printing after that with WorkSheets("Sheet1").PrintOut
0
 

Author Comment

by:Svgmassive
ID: 40025714
macro shadow the union created a second page,Everything should fit on one page. thanks
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 40025901
You can set all of the print layout features using the PageSetup member of sheets; you'll have to set two properties here:
with Worksheets("Sheet1").PageSetup
  .PrintArea = Union("$C$1:$P$19", "$C$38:$P$51")
  .FitToPagesTall = 1
  .FitToPagesWide = 1
end with

Open in new window

This scales the printable area into a single page.
You can set the same whether you need gridlines, header/footer and so on, just see the VBA help for PageSetup.
0
 

Author Comment

by:Svgmassive
ID: 40026157
can you attach a demo file?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 40026231
The only way is to copy the desired range to a new sheet then set the print area of the new sheet.
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 40026964
In the Print dialogue, there is an option to Print only selected area. By default if this is not selected, the print range will be the whole sheet.

You could automate the selection of the Selected Area option with a VBA button but whats the point when there is already that option in the Standard print options?

Thanks
Rob H
0
 

Author Comment

by:Svgmassive
ID: 40057805
i guess my next option would be to hide/show the rows
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 40058312
Did you look at the options in the Print setup? From your description, this does what you want.
0
 

Author Comment

by:Svgmassive
ID: 40083870
i tried them
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40419320
I've requested that this question be closed as follows:

Accepted answer: 250 points for MacroShadow's comment #a40025671
Assisted answer: 250 points for Qlemo's comment #a40025679

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Keyboard shortcuts for Back & Forward QAT arrows in Excel 3 56
Excel ODBC connection error 3 31
Macro 6 48
Excel 2010 - Populate a formula in multiple cells 6 23
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,…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

929 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now