'create an app object only once
If qtApp = Nothing then
Set qtApp = Nothing then
End if
'qtApp.Test.Settings.Run.EndIteration = 6 in your case
If Environment("TestIteration") = qtApp.Test.Setting.Run.EndIteration Then
MsgBox "This is the last iteration!"
Set qtApp = Nothing
End if