A scanning probe microscope has a cantilever mounted to undergo oscillation movement over a surface of a sample. The cantilever has a probe on a distal end thereof. A Z-axis controlling amount calculating mechanism calculates a controlling amount for keeping constant an oscillation amount of the cantilever. A Z-axis driving mechanism drives in a Z direction the cantilever or the sample in accordance with the controlling amount from the Z-axis controlling amount calculating mechanism. A driving range limiting device limits a driving range of the Z-axis driving mechanism. A driving range setting device optionally sets the driving range of the Z-axis driving mechanism.