you could try the likes of:
=SUMIF($A$2:$A$5,"*aaa",$B$2:$B$5)
but the asterisk means any characters, any number of them, including none. So it will find
aaa anywhere in the cell.
If this isn't suitable then let's get real world; put together and attach a workbook with just 2 columns of raw data:
- a column with the full range of the kinds of instances where you want aaa to be counted, and some where you don't want them to be counted
- a column with some numbers that need summing
then:
- a column with your attempt(s) at a formula
- a column indicating whether the row should be included in the summing or not