Refitting Cable to Rear Derailleur
Are you sure the cable is clamped correctly? Having that wrong can change the amount the derailleur moves for a given amount of pull (in fact it's sometimes done deliberately to use mismatched components - http://sheldonbrown.com/drivetrain-mixing.shtml#alternate).
Otherwise, make sure the cable moves smoothly through the housing and that the hanger isn't bent, then work through:
http://www.parktool.com/blog/repair-help/rear-derailler-adjustments-derailleur and/or
http://sheldonbrown.com/derailer-adjustment.html