Bike not changing correctly between two gears I have only recently started riding to work and I've been given a bike by a friend which is in reasonably good shape.

For the way things are working out I keep the front gear in the same position and change the back one between 4, 5 and 6.

The trip is very hilly so I like to switch over to 6 as I near the top of a hill so I can continue pedaling as soon as possible at the base of the next hill.

However, the bike changes quite readily between all other gears 1 - 5, except going up from 5 to 6. Going down 6 - 5 works fine. This means more effort when trying to go up the next hill. Sometimes the gear kicks in just before I want to switch back down to 5 again.

There is also a 7th gear on the back that I don't use, so the 6th is not the highest choice.

This problem occurs regardless of if I'm going up, down or on a flat grade. It also doesn't help if I try switching back down to 5 and trying again, it just seems to kick in randomly.

Any suggestions on what I can see could be causing this.
How many miles on this bike?  If over 5000 miles (8000km) then your rear gear cluster may be worn out.  Your symptoms are most strongly suggestive of that.

Otherwise, the first thing to do is to clean the derailer real well.  Lean the bike against a wall (derailer facing you) outside somewhere where a few oil stains won't be a problem.  Shove some newspaper or cardboard up behind the derailer and drape it over the tire, to keep stuff from dripping on the tire.  Then spray the derailer well with a spray solvent (WD40 in the US) and scrub it with an old toothbrush.  Dry the derailer well with an old rag, and lubricate with chain oil.

With the derailer clean, swivel it back and forth by hand and notice if it seems to be twisting in parallel with the chain and sprockets or is perhaps bent so that it goes at an angle.  If it seems bent (which happens from dropping the bike on its side) then the "derailer hanger" probably needs to be straightened.

Also, pay attention to the shifters and cables.  A little spray lube in the shifters and down the shifter cable housings is generally all that's needed here, unless the cables are badly corroded or beginning to fray, in which case they need to be replaced.  Be careful, though, about what sort of lube you put on the shifters as most now have plastic components that can be damaged by strong solvents.

And, of course, it's probably time to adjust the derailer, but that a whole different post.