API:SpellTargetUnit

Selects unit as target for pending spell (usually indicated by wand icon when you've used a spell that is not applicable to currently selected target).

SpellTargetUnit(unit);

Parameter

 * unit
 * UnitId (e.g. "mouseover", "party1", "raid1", etc..)

See also:
API:SpellIsTargeting