Select Range to last used cell

J

Jules

In a macro I need to select an Range of cells (rows and columns) for
printing

The data in the spreadsheet is brought in via a database query and so
the bottom area has lots of blank rows, and a print page ends up with
half dozen blank pages.

Each time the data is refreshed there is going to be more or less rows,
so I cannot choose a specific range.

I've tried Special Cells Last Cell but it goes to the end of the blank
rows
Selection.SpecialCells(xlCellTypeLastCell).Select

Can't use Special Cells Blanks as there are couple in the data itself

I've tried selecting the area and then printng the selection but only
get 2 cells
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWindow.Selection.PrintOut copies:=1
Any ideas?
 
D

Don Guillett

one way
Sub getprintarea()
fr = ActiveCell.Row
fc = ActiveCell.Column
lr = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
lc = Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Column
Range(Cells(fr, fc), Cells(lr, lc)).PrintOut
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