ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing only rows with values - newbie question (https://www.excelbanter.com/excel-programming/309992-re-printing-only-rows-values-newbie-question.html)

Tom Ogilvy

Printing only rows with values - newbie question
 
The most robust is (assuming we can determine by looking at column A -
adjust as appropriate)

Dim rng as Range, Dim numColumns as Long
numColumns = 10
Set rng = Cells(rows.count,1).End(xlup)
do while Trim(rng.Text) = "" and rng.row 1
set rng = rng.offset(-1,0)
Loop
ActiveSheet.PageSetup.PrintArea = Range(cells(1,1), _
rng).Resize(,NumColumns).Address(external:=true)
ActiveSheet.Printout

--
Regards,
Tom Ogilvy



"Hansi" wrote in message
...
Hi.

I'm making a spreadsheet where I'm collecting a lot of prices. I've

figured
out how to sort them, but I'm getting a lot of empty cells in the bottom.
This cells has formulas, and culd later get data, so I cant delete them.

What
I would like to do, is to specify the range Excel should print. What I'm
lokking for, is the rownumber, since the number of columns are given. In
other words, how do I find the rownumber of the last cell with a value in

it,
and print it?

Regards

Hansi





All times are GMT +1. The time now is 11:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com