Instead of code, how about a formula to do exactly the same thing. It
works by nesting your VLOOKUP into an IF:
=IF(AND(B1<>"",ISNUMBER(SEARCH("total",D1,1))), your vlookup formula
here,"")