You cannot do this in Calc without external help. See http://ooomacros.org/user.php#104183 for a macro to do this.