Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Print Area propery

I would like to use the property Print Area. This property
requires two give two cells for the array: top-left corner
and the bottom-right one. The top-left corner is constant
at $A$1. The bottom right has a constant column "K" but
its row varies.

Worksheets("Sheet1").PageSetup.PrintArea = "$A$1:$K$?"

How could I specify the value for the row in the PrintArea
property taking into account that this value is calculated
as follows?

Column F is a validation list arranged in alphabetical
order. The six options for the validation list a 1.OPER
2.MISS 3.EXEM 4.DISC 5.REMO 6.COMI

Considering that entries are in alphabetical order, I
would like to print only up to the last 4.DISC included.
This means that the row of the bottom-left corner of the
array is the previous entry to the first one that
has "5.REMO" in column F

Can anyone provide me with the code?

Thank you very much,

Marc

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Print Area propery

You could use .find to search up that column:

Option Explicit

Sub testme()

Dim FoundCell As Range
Dim LookFor As String

LookFor = "4.DISC"
With Worksheets("Sheet1")
With .Range("F:F")
Set FoundCell = .Cells.Find(what:=LookFor, _
after:=.Cells(1), _
searchdirection:=xlPrevious, _
LookIn:=xlValues, lookat:=xlWhole, _
MatchCase:=False)
End With
If FoundCell Is Nothing Then
MsgBox "can't set range!"
Else
.PageSetup.PrintArea = "$A$1:K" & FoundCell.Row
End If

End With

End Sub

Watch out for the parms I used--xlwhole and matchcase.

Marc wrote:

I would like to use the property Print Area. This property
requires two give two cells for the array: top-left corner
and the bottom-right one. The top-left corner is constant
at $A$1. The bottom right has a constant column "K" but
its row varies.

Worksheets("Sheet1").PageSetup.PrintArea = "$A$1:$K$?"

How could I specify the value for the row in the PrintArea
property taking into account that this value is calculated
as follows?

Column F is a validation list arranged in alphabetical
order. The six options for the validation list a 1.OPER
2.MISS 3.EXEM 4.DISC 5.REMO 6.COMI

Considering that entries are in alphabetical order, I
would like to print only up to the last 4.DISC included.
This means that the row of the bottom-left corner of the
array is the previous entry to the first one that
has "5.REMO" in column F

Can anyone provide me with the code?

Thank you very much,

Marc


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set area in excel not giving me option to set print area? J Littlebear Excel Discussion (Misc queries) 4 April 23rd 23 09:04 PM
File, print area, clear area, is not working cblind New Users to Excel 2 September 12th 07 04:51 PM
print area across the freeze panes area tom Excel Worksheet Functions 2 January 6th 07 05:23 PM
How do you turn off a print area for a page? (no print area) Grunen Excel Discussion (Misc queries) 4 October 8th 05 07:46 PM
Listbox Propery code Mike Fogleman Excel Programming 3 January 1st 04 04:27 PM


All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"