As has been stated...check replace the cable and housing...maybe only the short length of housing from the chain stay to the rear derailleur is gunked up and restricting cable movement if that is a problem.
Before replacing the cable and housing though thoroughly clean the rear derailleur and chain, readjust the cable tension.