I have a simple Excel macro that prints out vehicle inspection sheets. This is a chore that is done monthly at work. The macro prints sheets based on what vehicles are in a list. The sheets are named for each vehicle number and the list the macro refers to are the vehicle numbers to be printed. It will print all the vehicles in the list from my computer but for some others users it will print the first two vehicle sheets and end. I have experienced this with other similar type macros here at work and have been meaning to ask if anyone knows what's going on for some time. The excel file is stored on the network and all printing is done to network printers. Most users here have Office 365. If I step through the macro on one of the computers that it fails on it works without incident. It makes me think there might a timing issue. The code follows.
Code:
Sub VehicleForms()
' Print Vehicle Inspection forms
Dim lastrow As Long
Dim shtName As String
Dim i As Long
' Activate the worksheet with the vehicle list in column M
Worksheets("Set Date").Activate
' Get the number of the last row
lastrow = Cells(Rows.Count, 13).End(xlUp).Row 'The 13 is column M
' This line is in case someone leaves a blank cell in the list
' the code will skip to the next row
On Error Resume Next
' Loop through the list in column M printing each sheet
For i = 2 To lastrow
shtName = Cells(i, 13)
Sheets(shtName).PrintOut Copies:=1
Next
End Sub