I am looking for a formula to calculate totals based on codes

I have the following formula

=IF(COUNTBLANK(W16:W411)=396,"",SUMIF(AV16:AV411,{"Can","Cus","Man","Not","Obs","Ret","Rep","Sto","Sup"},W16:W411))

which calculates everything I need but I would only like it to calculate if there is a "B" in column range W16:W411

Many thanks