Excel 2000 VBA: select filled cells for printing

A

aaabart

Hello, i would appreciate some help on the following:

Suppose I have a range A1:F200 which is an output of a macro
Always, the first couple of cells in column A are filled with different
texts and below those, the other cells of the column are filled with
the text "1"

I need a VBA code that automatically puts a print area around the range
that doesn't have "1" in the cell of column A. So, in that way I will
be able to print only the significant data which has a text other than
"1" in the first cell of the row.

Thanks !

Bart
 
D

Dave Ramage

If the data is entered into the cell by VBA code, it would
make sense to set up the print area at the same time- that
way you will already know where the first "1" is in column
A.

If this is not possible, here is a stand alone procedure
to do it:

Sub SetPrintArea()
Dim rngR As Range

Set rngR = Sheets("Sheet1").Columns(1).Find(what:="1",
lookat:=xlWhole, LookIn:=xlValues)

If Not rngR Is Nothing Then
Sheets("Sheet1").PageSetup.PrintArea = "A1:A" &
rngR.Row - 1
Else
Sheets("Sheet1").PageSetup.PrintArea = False
End If
End Sub

Cheers,
Dave.
 

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