The VBA is creating a string to create a formula in a worksheet. The target formula is

"=SUMIF(All!$A$2:$A$3000,"*"&$C$2&"*&$B10,All!F$2:F$3000)"

which looks in A2:A3000 for any cell that CONTAINS the strings in C2 and B10, and if so adds up the corresponding value in B2:B3000.

So if C2 = ABC and B10 = XYZ, the following cells match

- some text ABC some more text XYZ even more text
- some text ABC some more text XYZ
- ABC some more text XYZ even more text
- some text ABCXYZ
- ABCXYZ some text

and so the B values get summed. Thes cells fail

- some text AB C some more text XYZ even more text
- some text ABC some more text X YZ even more text
- some text XYZ some more text ABC even more text

and so the B values are not summed.