I don't see the pattern. Sometimes you go to -003 and sometimes you go to -025.
I think I'd create a new workbook.
If all the files are in the same folder, put the folder name in D1. If the
files vary, put the folder name in each cell (A1:Axxx). And put the number of
copies to be printed in that workbook in B1:Bxxx.
So it would either look like:
c:\my documents\excel\test\661-001.xls 3
c:\my documents\excel\test\661-002.xls 1
c:\my documents\excel\test\661-003.xls 2
etc...
or
661-001.xls 3 c:\my documents\excel\test
661-002.xls 1
661-003.xls 2
etc...
(D1 just because it's out of the way!)
Then you could create a macro that would read those cells and print the way you
want:
Option Explicit
Sub testme01()
Dim myCell As Range
Dim myFileName As String
Dim myFolderName As String
Dim mstrWks As Worksheet
Dim wkbk As Workbook
Dim wks As Worksheet
Dim testStr As String
Dim iCtr As Long
Dim okToPrint As Boolean
Dim QtyToPrint As Variant
Set mstrWks = ThisWorkbook.Worksheets("sheet1")
With mstrWks
.Range("c:C").ClearContents
If IsEmpty(.Range("d1")) Then
myFolderName = ""
Else
myFolderName = .Range("d1").Value
If Right(myFolderName, 1) <> "\" Then
myFolderName = myFolderName & "\"
End If
End If
For Each myCell In .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
myFileName = myFolderName & myCell.Value
testStr = ""
On Error Resume Next
testStr = Dir(myFileName)
On Error GoTo 0
If testStr = "" Then
myCell.Offset(0, 2).Value = "Missing!"
Else
Set wkbk = Workbooks.Open(Filename:=myFileName, ReadOnly:=True)
QtyToPrint = myCell.Offset(0, 1).Value
okToPrint = False
If IsNumeric(QtyToPrint) Then
If QtyToPrint > 0 _
And QtyToPrint < 10 Then
okToPrint = True
End If
End If
If okToPrint Then
For Each wks In wkbk.Worksheets
wks.PrintOut _
copies:=myCell.Offset(0, 1).Value, preview:=True
Next wks
' ' or
' For iCtr = 1 To 2
' wkbk.Worksheets(iCtr).PrintOut _
' copies:=myCell.Offset(0, 1).Value, preview:=True
' Next iCtr
Else
myCell.Offset(0, 2).Value = "Quantity Error!"
End If
wkbk.Close savechanges:=False
End If
Next myCell
If Application.CountA(.Range("c:c")) > 0 Then
MsgBox "At least one workbook error!"
End If
End With
End Sub
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
I have preview:=true to save paper while testing.
I figured that 1-9 copies was sufficient. Change this portion if you want to
allow larger values:
And QtyToPrint < 10 Then
This portion has two variations.
If you want to print all the worksheets, use the first version.
For Each wks In wkbk.Worksheets
wks.PrintOut _
copies:=myCell.Offset(0, 1).Value, preview:=True
Next wks
if you know that you want to print 2 worksheets, use this version.
' ' or
' For iCtr = 1 To 2
' wkbk.Worksheets(iCtr).PrintOut _
' copies:=myCell.Offset(0, 1).Value, preview:=True
' Next iCtr