Hello,

I have this code then works when it enters the if statement but when the condition is not satisfied then it returns runtime error 9, subscript out of range. Why does it work when the condition is satisfied and not when it doesn't?


If Sheets("Trial " & Trial_Name).name = "Trial " & Trial_Name Then
MsgBox "You have to rename your trial output (Cell E8)"
Exit Sub
End If
Trial name is a string and when the condition is satisfied then the messgage box apeared.

Thank you very much for the help. Have a nice day.

-Rob