View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_313_] Leith Ross[_313_] is offline
external usenet poster
 
Posts: 1
Default Macro - Set Print Area for Changing Data Area


Hello Karen,

You don't say which 7 columns you are using, so I am going to use A t
G in this example. You can change it later if you need to. Insert a VB
module into your workbook and paste this code into it. You can create
button to call this macro for you, or simply run it from the Macro Lis
by pressing ALT + F8 and selecting it.


Code
-------------------
Public Sub AutoSetPrintArea()

Dim LastRow As Long

With ActiveSheet
LastRow = .Cells(.Rows.Count, "D").End(xlUp)
.PageSetup.PrintArea = "A1:G" & LastRow
End With

End Sub

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

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48749