View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Binzelli[_7_] Binzelli[_7_] is offline
external usenet poster
 
Posts: 1
Default SETTING PRINT AREA IN VBA

Frankie,

I assume you want to set the printarea from A1 to the last cell in th
sheet. The code below selects the last cel
(ActiveCell.SpecialCells(xlLastCell).Select) and assigns its rownumbe
to the variable Lastrow. (Lastrow = Selection.Row). Then the strin
"SelString" defining the range to be selected is made from tha
variable (SelString = "A1:D" & Lastrow). This should do the trick.


Code
-------------------

Sub SetPrintArea

Dim Lastrow As Double
Dim SelString As String

ActiveCell.SpecialCells(xlLastCell).Select
Lastrow = Selection.Row
SelString = "A1:D" & Lastrow

ActiveSheet.PageSetup.PrintArea = SelString

End Sub

-------------------


Good luc

--
Message posted from http://www.ExcelForum.com