ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Define a dynamic Print_Area (https://www.excelbanter.com/excel-discussion-misc-queries/447979-define-dynamic-print_area.html)

John[_34_]

Define a dynamic Print_Area
 
I've been searching on the internet and have found just enough tidbits
to get me on the road to frustration

I would like to set up a dyn. Print_Area from A1 to column K(n).
I tried:
1. =INDIRECT("A1:K"&COUNTIF(UK!A:A,"0"))
2. =OFFSET(UK!$A$1,0,0,Countif(UK!$A:$A,"<"&0),11)

The number seems the one that works better but not as I expected.
Where am I wrong?
Thanks for any help
Regards
John

Claus Busch

Define a dynamic Print_Area
 
Hi John,

Am Sun, 13 Jan 2013 11:32:15 +0100 schrieb John:

1. =INDIRECT("A1:K"&COUNTIF(UK!A:A,"0"))
2. =OFFSET(UK!$A$1,0,0,Countif(UK!$A:$A,"<"&0),11)


try:
=OFFSET(UK!$A$1,,,COUNTA(UK!$A:$A),11)


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Claus Busch

Define a dynamic Print_Area
 
Hi John,

Am Sun, 13 Jan 2013 11:42:24 +0100 schrieb Claus Busch:

try:
=OFFSET(UK!$A$1,,,COUNTA(UK!$A:$A),11)


create this range on the worksheet and give it the name myRange.
Then you can use the name for your printarea:
With ActiveSheet.PageSetup
.PrintArea = "myRange"
End With

Or you do it in VBA competely:

Sub Test()
Dim LRow As Long
Dim LCAddr As String

With ActiveSheet
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
LCAddr = .Cells(LRow, 11).Address
With .PageSetup
.PrintArea = "$A$1:" & LCAddr
End With
End With
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

John[_34_]

Define a dynamic Print_Area
 
Hallo Claus,
thanks for your suggestions and help.
I'll use the VBA solutions.

Thanks again.
John.




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

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