auto suppress unused rows when printing

E

Erin

I've got a worksheet designed to do estimates (for
products). It's set-up for the largest possible number
of items included in a quote for calculation purposes.
The end users are sales people, with end viewer being the
customer. I'd like to automatically suppress any unused
rows (product line item) when printing. How do I do
this???
 
T

Tom Rollins

I recently wrote a macro that does this that I use within a workbook that I
use like a template. It was needed because there is formatting that extends
to the worst case size of the sheets and most often they do not need all
that room. I placed the macro in in the ThisWorkbook object. You can
probably tune it to your needs.
---------------------------------------
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim pntrng As Range


lastrow = ActiveSheet.Range("a65536").End(xlUp).Row
If ActiveSheet.Name = "Move_Info" Then
Set pntrng = Range("a6").CurrentRegion
lastcol = pntrng.Columns.Count
Else
lastcol = 12
End If
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(lastrow + 1,
lastcol)).Address
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top