ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set Print Area (https://www.excelbanter.com/excel-programming/363028-set-print-area.html)

TimT

Set Print Area
 
hey all,
I'm trying to set the print area for a sheet after data is updated.
The populating range can vary constantly so I need to determine the last
column and the last row.
I think I'm missing it on the column part because I need to know the Row
Letter instead of the value?

Please help!

I'm using the following code:

Private Sub btnUpdate_Click()

Call K1_Review ' updates the current sheet

'set print area

Dim LRow As Integer
LRow = Range("A65536").End(xlUp).Row
Dim LCol As String
LCol = Range("CA18").End(xlToLeft).Column

'Range("A4: & LCol & LRow").Select
ActiveSheet.PageSetup.printarea = "$A$4:$" & LCol & "$" & LRow

End Sub

Don Guillett

Set Print Area
 
try something like

LCol = Range("CA18").End(xlToLeft).Column
range(cells(4,"a"),cells(lrow,lcol)).printout

or
LCol = Range("CA18").End(xlToLeft).Column

activesheet.pagesetup.printarea=range(cells(4,"a") ,cells(lrow,lcol)).address




--
Don Guillett
SalesAid Software

"TimT" wrote in message
...
hey all,
I'm trying to set the print area for a sheet after data is updated.
The populating range can vary constantly so I need to determine the last
column and the last row.
I think I'm missing it on the column part because I need to know the Row
Letter instead of the value?

Please help!

I'm using the following code:

Private Sub btnUpdate_Click()

Call K1_Review ' updates the current sheet

'set print area

Dim LRow As Integer
LRow = Range("A65536").End(xlUp).Row
Dim LCol As String
LCol = Range("CA18").End(xlToLeft).Column

'Range("A4: & LCol & LRow").Select
ActiveSheet.PageSetup.printarea = "$A$4:$" & LCol & "$" & LRow

End Sub




Don Guillett

Set Print Area
 
actually this might be better

LRow = cells(rows.count,"a").End(xlUp).Row
LCol = cells(18,columns.count).End(xlToLeft).Column
range(cells(4,"a"),cells(lrow,lcol)).printout


--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
try something like

LCol = Range("CA18").End(xlToLeft).Column
range(cells(4,"a"),cells(lrow,lcol)).printout

or
LCol = Range("CA18").End(xlToLeft).Column

activesheet.pagesetup.printarea=range(cells(4,"a") ,cells(lrow,lcol)).address




--
Don Guillett
SalesAid Software

"TimT" wrote in message
...
hey all,
I'm trying to set the print area for a sheet after data is updated.
The populating range can vary constantly so I need to determine the last
column and the last row.
I think I'm missing it on the column part because I need to know the Row
Letter instead of the value?

Please help!

I'm using the following code:

Private Sub btnUpdate_Click()

Call K1_Review ' updates the current sheet

'set print area

Dim LRow As Integer
LRow = Range("A65536").End(xlUp).Row
Dim LCol As String
LCol = Range("CA18").End(xlToLeft).Column

'Range("A4: & LCol & LRow").Select
ActiveSheet.PageSetup.printarea = "$A$4:$" & LCol & "$" & LRow

End Sub







All times are GMT +1. The time now is 04:04 PM.

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