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