• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA print

Pierre

Member
Hello,
I would like to automatize the print of a document for drivers: on an excel file I have one sheet with the paper to give to driver with the route number and some different info, and another sheet, I have the list of all route numbers.
I would like to automatize the printing of the sheet "trip_paper", in order to print one trip paper for each of the route that are in the sheet "data"
Could anyone help?

Thanks in advance
 

Attachments

  • Trip_print.xlsm
    9.4 KB · Views: 9
Try this in a code module
You can customize it to suit your requirements

Code:
Sub Print_Loop()

Worksheets("Data").Select

Dim lr As Integer
lr = Range("B" & Rows.Count).End(xlUp).Row

Sheets("Trip_paper").Select

For i = 3 To lr
   Range("C2").Value = Sheets("Data").Cells(i, 3)
  
   Activesheet.Calculate
  
   ActiveSheet.PageSetup.PrintArea = "$A$1:$D$10" 'Change the range to suit
   ActiveWindow.SelectedSheets.PrintOut _
      Copies:=1, _
      Collate:=True, _
      IgnorePrintAreas:=False
Next i

End Sub
 
Back
Top