View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Help with offset

Add + 1 to the row reference in the function i.e:

Function LastRowRange(sh As Worksheet)

On Error Resume Next
LastRowRange = sh.Range("A:A").Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row + 1
On Error GoTo 0

End Function

Hope this helps
Rowan

lk wrote:
Hi all,

I have the code below (kindly provided by a genius from this forum) that
determines the active print range for a sheet. It works perfectly, however,
I wish to expand this returned range by 1 row. I have experimented with
offset but so far have had no success. Any ideas would be welcomed!

With ActiveSheet
.PageSetup.PrintArea = ""
.PageSetup.PrintArea = ActiveSheet.Range("A1:Q" &
LastRowRange(ActiveSheet)).Address
End With

Function LastRowRange(sh As Worksheet)
'This function determines the active print range for a list and returns a
range object.

On Error Resume Next
LastRowRange = sh.Range("A:A").Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0

End Function