Hi all--
having an issue with some VBA code. The main goal is to print the desired sheets based on the numbers entered. Ex. user enters 123, 456, and 789. This will open sheets of those names and print them out. I am trying to design it so that if they enter a number that doesn't have a corresponding workbook named after it, it will skip this one and go on to the next (and doesn't enter "Printed" in the cell next to it.). With my current code, if there is one incorrect number, it works fine. However, if there are two in a row, it stops there and doesn't continue even if there are legitimate numbers after.
Please let me know if that makes sense, here is my code:
Sub DailyPrints()
Range("C2:C25").Select
Selection.ClearContents
Dim CellValue As String
Dim n As Integer
n = 2
Application.ScreenUpdating = False
Sheets("Daily Prints").Range("A" & n).Select
Do Until IsEmpty(Range("A" & n))
Application.DisplayAlerts = False
CellValue = Sheets("Daily Prints").Range("A" & n).Value
Workbooks.Open "Z:\5. Postponement\Pick to Cart\" & CellValue & ".xlsx"
On Error GoTo 30
Call Prints
ActiveWindow.Close
Range("A" & n).Offset(0, 2).Value = "Printed"
30 n = n + 1
Err.Clear
Application.Goto (ActiveWorkbook.Sheets("Daily Prints").Range("A" & n))
Loop
GetOut:
Application.DisplayAlerts = True
End Sub
Bookmarks