One of the challenges when applying managed pressure drilling (MPD) offshore on a floating rig is the wave-induced heaving motion of the rig. During drillstring extensions, the drillstring is rigidly attached to the rig and follows the rig's heaving motion. This induces pressure oscillations in the well that can violate pressure margins, in particular in rough conditions and when margins are tight. In order to enable drilling operations under such conditions, the pressure oscillations are to be attenuated by use of a controllable valve installed in the bottomhole assembly (BHA) at the bottom of the drillstring. The subject of this paper is the controller design for the valve flow based on measurements of the BHA movement and downhole pressure. Using a frequency-domain approach, the control law is designed to, in case of downwards BHA movement, reduce the valve flow to compensate the mud being displaced by the BHA and the flow due to mud clinging to the moving drillstring. Controlling the valve flow in such a manner creates large differential pressures over the valve that can potentially destabilize the BHA motion, which must be taken into consideration in the control design. Stability and performance of the closed-loop system are verified in simulations using a high-fidelity model of the drilling mud and elastic drillstring.