View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Simon Lloyd[_1022_] Simon Lloyd[_1022_] is offline
external usenet poster
 
Posts: 1
Default Print Area Set for Columns but Not Rows


This should do what you want!
Code:
--------------------
Sub PrepareSheet()
Dim lRow As Long
lRow = ActiveSheet.Range("N" & Rows.Count).End(xlUp).Row
With ActiveSheet.PageSetup
.PrintArea = "$A$1:$N$" & lRow
.Zoom = False
.FitToPagesWide = 1
End With
End Sub
--------------------


Swingdancer42;216398 Wrote:
Help,

I thought this would be a redundant question, but I can't seem to find
the
answer in any of the previous posts. I have a spreadsheet with Columns
A:R,
but I only want columns A:N to print. I also want Excel to
automatically
print only up to the last row with data entered. Looking through all
the
previous posts, I thought this would do the trick:

Sub PrepareSheet(sht As Worksheet)
Dim lRow As Long
lRow = sht.Range("A:N").SpecialCells(xlCellTypeLastCell). Row
With sht.PageSetup
.PrintArea = "$A$1:$N" & lRow
.Zoom = False
.FitToPagesWide = 1
End With
End Sub

Unfortunately this is only accomplishing half of my desires - while
this
DOES only print the rows with inputs, it's printing all my columns
(instead
of just columns A to N). Can anybody help me? What's the code I should
be
using?

Thanks in advance for any help you can provide!!!



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=59441