When replacing a cable (shifting or brake),
1) Turn the cable tensioner in all the way so that it isn't putting any additional tension on the cable.
2) While using pliers on the end of the new cable to pull it as taut as possible, fasten the screw that holds the cable in place.
3) Finally, use the tension adjuster to get the cable taut enough to shift to all the gears.