Sure....
=SUMIF($A$1:$A$40,5014,$L$1:$L$40)-SUMIF($A$1:$A$40,5014,$M$1:$M$40)
Try thinking of the SUMIF like this:
=SUMIF(
Find items in this range,
That match this value,
When you find them...add the corresponding items from this range)
So, in your example, the first SUMIF:
=SUMIF($A$1:$A$40,5014,$L$1:$L$40)
Works this way:
=SUMIF(
Find Items in this range: $A$1:$A$40,
That match: 5014,
When you find them...add the corrsponding items from this range:
$L$1:$L$40)
The first SUMIF adds the total matched values from Column L.
The 2nd SUMIF subtracts the total matched values from Column M.
Does that help?
Ron