The End If has to be there. I think the following line may be the
issue
And (InStr(1, x.Value, " ", vbTextCompare) - 1 > 0) Then
x.Value = Trim(Replace(x.Value, y, "", 1, 1, vbTextCompare))
Exit For
End If
If Then statements can appear on one line. If so, you don't need the
End
If. If the IF/THEN is being treated as one line then the Exit For will
be
outside of the IF statement, causing the macro to end after looping
through
only the first element of Array1 (which is "The"). In this case, the
Then
statement has two lines of code requiring the End If.
Make sure the code appears exactly as I've written it above. Also,
you
don't need to include lowercase "a" "an" "the" in the array. For
comparison
purposes the macro converts everything to uppercase (but doesn't change
how
it appears in the spreadsheet).