ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2000 VBA: select filled cells for printing (https://www.excelbanter.com/excel-programming/276055-excel-2000-vba-select-filled-cells-printing.html)

aaabart

Excel 2000 VBA: select filled cells for printing
 
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

Dave Ramage[_2_]

Excel 2000 VBA: select filled cells for printing
 
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.
-----Original Message-----
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
.



All times are GMT +1. The time now is 03:35 AM.

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