The EVs gained by defeating a Pokemon are awarded,
in full, to every Pokemon who receives a share of the EXP points. So if a Pokemon awards 2 Speed EVs, every Pokemon that gains EXP after its defeat (whether by battling the Pokemon or by holding an EXP Share) will also gain the 2 Speed EVs.
The formula for EXP points is different, and involves dividing the total number of points between the battling Pokemon. If you also have some Pokemon with EXP. Share attached, here's the formula for finding out how many EXP each Pokemon will get:
Half of the total EXP points from defeating a Pokemon will be shared equally between those Pokemon in your party who participated in the battle (even if they are holding an EXP Share).
The other half of the EXP points will be shared equally between all Pokemon holding EXP Share (including those who participated in the battle).
If a Pokemon participates in a battle while holding an EXP Share, it gets some of both.
So, suppose I've got
,
,
and
in my party.
I battle a Pokemon, and
,
and
all take part in defeating it.
and
each have an EXP Share.
If the Pokemon I defeated gives 1200 EXP points in total, half of them will be awarded to the battling Pokemon, and the other half will be awarded to Pokemon holding EXP Share.
So,
will get 200 (its share of the battle EXP)
will get 200 (also battle EXP)
will get 300 (from the EXP Share)
will get 500 (from both the battle and the EXP Share).
Complicated, no?