MR spectroscopy and many MR imaging methods benefit from a well-shimmed magnet. We have developed a pulse sequence which enables fast and accurate measurement of three-dimensional field maps in vivo, and a data analysis package that allows calculation of shim currents to optimally shim arbitrary selected volumes. A data link to the shim power supply allows automatic update of currents. No intervention by the operator is required. Typical in vivo shimming time is less than 5 min. Performance analysis, phantom, and in vivo results are presented.