Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Printing a Dynamic Range

I am trying to print out a Range of Data that can change as new Rowss
are added.

Here is my Code::-

Option Explicit


Public Sub PrintData()
Dim lrow As Range
Dim rc As Integer
Dim ar As Integer
Dim Response As String

Application.ScreenUpdating = False

Sheets(1).Activate

Set lrow = Sheet1.Range("A" & Rows.Count).End(xlUp)

lrow.Activate
ar = ActiveCell.row

Range(Cells(1, "a"), Cells(ar, "M")).Select ' Selects Print Area

MsgBox ("Ensure that the Printer is on!")


ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$4"
.PrintTitleColumns = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(0.5)
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
Response = MsgBox("Print in Black and White?",
vbYesNo)
If Response = vbYes Then
.BlackAndWhite = True
Else
.BlackAndWhite = False
End If
.Zoom = 100
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("A5").Select

Application.ScreenUpdating = True


End Sub

This usually Prints only the Cell at A1 and goes no further. Is there
any way to make the print area dynamic?

Thanks for any Help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Printing a Dynamic Range

Range("PrintArea").printout


--
HTH
Roger
Shaftesbury (UK)


"Stumped" wrote in message
oups.com...
I am trying to print out a Range of Data that can change as new Rowss
are added.

Here is my Code::-

Option Explicit


Public Sub PrintData()
Dim lrow As Range
Dim rc As Integer
Dim ar As Integer
Dim Response As String

Application.ScreenUpdating = False

Sheets(1).Activate

Set lrow = Sheet1.Range("A" & Rows.Count).End(xlUp)

lrow.Activate
ar = ActiveCell.row

Range(Cells(1, "a"), Cells(ar, "M")).Select ' Selects Print Area

MsgBox ("Ensure that the Printer is on!")


ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$4"
.PrintTitleColumns = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(0.5)
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
Response = MsgBox("Print in Black and White?",
vbYesNo)
If Response = vbYes Then
.BlackAndWhite = True
Else
.BlackAndWhite = False
End If
.Zoom = 100
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("A5").Select

Application.ScreenUpdating = True


End Sub

This usually Prints only the Cell at A1 and goes no further. Is there
any way to make the print area dynamic?

Thanks for any Help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Printing a Dynamic Range


Try changing this...
ar = ActiveCell.row
Range(Cells(1, "a"), Cells(ar, "M")).Select ' Selects Print Area
MsgBox ("Ensure that the Printer is on!")
ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address

To...
set lrow = Range(Cells(1, "a"), lrow)
ActiveSheet.PageSetup.PrintArea = lrow.Address
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"Stumped"
wrote in message
I am trying to print out a Range of Data that can change as new Rowss
are added.
Here is my Code::-
Option Explicit

Public Sub PrintData()
Dim lrow As Range
Dim rc As Integer
Dim ar As Integer
Dim Response As String

Application.ScreenUpdating = False

Sheets(1).Activate

Set lrow = Sheet1.Range("A" & Rows.Count).End(xlUp)

lrow.Activate
ar = ActiveCell.row

Range(Cells(1, "a"), Cells(ar, "M")).Select ' Selects Print Area
MsgBox ("Ensure that the Printer is on!")

ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$4"
.PrintTitleColumns = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(0.5)
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
Response = MsgBox("Print in Black and White?", vbYesNo)
If Response = vbYes Then
.BlackAndWhite = True
Else
.BlackAndWhite = False
End If
.Zoom = 100
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("A5").Select
Application.ScreenUpdating = True
End Sub

This usually Prints only the Cell at A1 and goes no further. Is there
any way to make the print area dynamic?
Thanks for any Help.

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
Printing dynamic labels donpro Excel Discussion (Misc queries) 0 February 11th 10 08:31 PM
Automated Dynamic Printing Area? smplogc Excel Discussion (Misc queries) 9 April 30th 06 05:13 PM
getting the absolute range address from a dynamic named range junoon Excel Programming 2 March 21st 06 01:29 PM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
select dynamic range with dynamic start point Juli Excel Programming 1 August 31st 05 12:05 AM


All times are GMT +1. The time now is 01:20 PM.

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

About Us

"It's about Microsoft Excel"