Hi
I have a small problem in the ORDER that my pdf's are generated compared to the way this order is displayed on my main front sheet.
My code loops through and checks for topics on which a candidate scored than 75% on a variety of topics. It then produces 10 pdf's on those topics only with a main cover page.
The problem I have is that order of the pdf names on the front page is NOT in the same order as when they are generated. This confuses the candidate who could see e.g. "Bears.pdf", "Dogs.pdf", etc. on the front page but the 1st pdf in the booklet could be "Cats.pdf". Could I possibly add a number at the beginning of each pdf (e.g. 1,2,3 etc.) so that they are in the same order as the ones displayed on my main front sheet?
Here is the code for the main front page with the order of the pdfs being displayed.
'UPDATE WORKLISTS
For i = 2 To 3
count = 1
'ADD IF STATEMENT FOR EACH WORKLIST
If i = 2 Then
LastRow = ActiveSheet.Cells(Rows.count, 4).End(xlUp).Row
Set rng = Worksheets("Main").Range("D5:D" & LastRow)
ElseIf i = 3 Then
LastRow = ActiveSheet.Cells(Rows.count, 12).End(xlUp).Row
Set rng = Worksheets("Main").Range("L5:L" & LastRow)
End If
Set dnary = CreateObject("Scripting.Dictionary")
For Each cell In rng
If cell.Offset(0, 3) <= 0.75 And count <= 10 Then
If Not dnary.Exists(cell.Value) Then
dnary.Add cell.Value, 1
'CHANGE SHEET NUMBER TO MATCHING WORKLIST SHEET NUMBER
Worksheets(i).Range("A" & count + 1) = count
count = count + 1
End If
End If
Next cell
Next i
End If
Target.Select
Here is part of my loop code to generate the pdfs
'Iterate each candidate reference to update Main sheet.
For i = 1 To rng2.Rows.count
wsM.[F1] = rng2(i).Offset(, -1) 'Reference number for candidate
rn = Trim(wsM.[F1])
count = 1
'Iterate each file item and copy files and make pdf for candidate.
For Each c1 In rng1
If c1.Offset(, 3) <= 0.75 And count <= 10 And _
Not .FileExists(p2 & Trim(wsM.[c2]) & "\" & Trim(wsM.[c2]) & rn & "." & .GetFileName(c1)) Then
If .FileExists(c1) Then
'.CopyFile c1, p2 & rn & "." & .GetFileName(c1), True
.CopyFile c1, p2 & Trim(wsM.[c2]) & "\" & Trim(wsM.[c2]) & rn & "." & .GetFileName(c1)
count = count + 1
End If
End If
Next c1
I hope the above makes sense. Still new to this and still learning. Any help would be greatly appreciated.
TIA
Bookmarks