=MID(D8,LEN(D8)-2,2) gives you the first 2 of the last 3 characters of D2 so instead of using

MID(D8,LEN(D8)-2,2)="SR"

try using COUNTIF instead, i.e.

COUNTIF(D2,"*SR?")=1

That will give you TRUE/FALSE depending on whether "SR" occurs in that position or not.....without any errors