I need help with a project. I set up a workbook to track production data and am having trouble with the printing code. The primary worksheet (employeedata) pulls data from a txt file based on an operator code that you enter into a cell. Upon entering, the worksheet refreshes with the data corresponding to the operator code. This is done by using an array to cycle through the txt file and displaying each instance.
I am trying to create a Print All button to cycle through each operator in the table, automatically enter it into the cell and print the page. here is my code so far. It will show the first sheet fine but will go into an endless loop trying to print. I have a button that will print each individually, but that would be very time consuming.
I am trying to create a Print All button to cycle through each operator in the table, automatically enter it into the cell and print the page. here is my code so far. It will show the first sheet fine but will go into an endless loop trying to print. I have a button that will print each individually, but that would be very time consuming.
Code:
Sub PrintAll() ' PrintAll Macro
' Select cell A2, *first line of data*.
Application.ScreenUpdating = False
Worksheets("Employees").Activate
ActiveSheet.Range("A2").Select
' Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)
'Copy the data
Sheets("Employees").Range("a2").Copy
'Activate the destination worksheet
Sheets("Employeedata").Activate
'Select the target range
Range("a2").Select
'Paste in the target destination
Worksheets("EmployeeData").Range("$a$2").Select
ActiveSheet.Paste
Application.SendKeys "{ENTER}"
Worksheets("EmployeeData").PrintOut From:=1, TO:=2, Preview:=True, ignoreprintareas:=false
' Step down 1 row from present location.
Worksheets("Employees").Activate
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Last edited by a moderator: