How could I make the code to run and stop even with one data row.
Any help would be kindly appreciated.
Code: Select all
Sub Generate()
Dim IDCell As Range
Dim strID As String
Dim mssgResponse As String
Dim rng As Range
On Error Resume Next
MkDir ThisWorkbook.Path & "\Employee Awards"
strID = Sheets("employees").Range("B5").End(xlDown).Address
For Each IDCell In Sheets("employees").Range("$B$5:" & strID)
Sheets("awards").Range("B5") = IDCell
Set rng = Sheets("awards").Range("F3:F39")
rng.ExportAsFixedFormat Type:=xlTypePDF, fileName:= _
ThisWorkbook.Path & "\Employee Awards\" & Sheets("employees").Range("B6").Value & ".pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=True, _
OpenAfterPublish:=False
Next IDCell
MsgBox "finished successfully.", vbInformation, "Management System"
End Sub