aalphons
05-14-2008, 10:19 PM
The code below prints each selected row to a separate page.
How do I modify to print all selected rows continuously on one page?
Thanks!
Private Sub cmdPrintSelected_Click()
Dim DataWks As Worksheet
Dim RptWks As Worksheet
Dim myRng As Range
Dim myCell As Range
Dim iCtr As Long
Dim myAddresses As Variant
Dim Records As Long
Set DataWks = Worksheets("Log")
Set RptWks = Worksheets("Report1")
myAddresses = Array("D1", "F2", "F3", "F1", "A1", "A2", "A3", "B3", "C3", "D2", _"D3", "A5", "F5", "A7")
With DataWks
Set myRng = .Range("B4", .Cells(.Rows.Count, "B").End(xlUp))
End With
For Each myCell In myRng.Cells
With myCell
If IsEmpty(.Offset(0, -1)) Then
Else
.Offset(0, -1).ClearContents
For iCtr = LBound(myAddresses) To UBound(myAddresses)
RptWks.Range(myAddresses(iCtr)).Value _
= myCell.Offset(0, iCtr).Value
Next iCtr
Application.Calculate
RptWks.PrintOut Preview:=True
Records = Records + 1
'RptWks.Range("A1:G50").ClearContents
End If
End With
Next myCell
MsgBox Records & " Record(s) Printed."
End Sub
How do I modify to print all selected rows continuously on one page?
Thanks!
Private Sub cmdPrintSelected_Click()
Dim DataWks As Worksheet
Dim RptWks As Worksheet
Dim myRng As Range
Dim myCell As Range
Dim iCtr As Long
Dim myAddresses As Variant
Dim Records As Long
Set DataWks = Worksheets("Log")
Set RptWks = Worksheets("Report1")
myAddresses = Array("D1", "F2", "F3", "F1", "A1", "A2", "A3", "B3", "C3", "D2", _"D3", "A5", "F5", "A7")
With DataWks
Set myRng = .Range("B4", .Cells(.Rows.Count, "B").End(xlUp))
End With
For Each myCell In myRng.Cells
With myCell
If IsEmpty(.Offset(0, -1)) Then
Else
.Offset(0, -1).ClearContents
For iCtr = LBound(myAddresses) To UBound(myAddresses)
RptWks.Range(myAddresses(iCtr)).Value _
= myCell.Offset(0, iCtr).Value
Next iCtr
Application.Calculate
RptWks.PrintOut Preview:=True
Records = Records + 1
'RptWks.Range("A1:G50").ClearContents
End If
End With
Next myCell
MsgBox Records & " Record(s) Printed."
End Sub