diff options
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index d40e93608d6e..87bc8e5fe8d6 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1741,7 +1741,17 @@ void ScInterpreter::ScRandomImpl( const std::function<double( double fFirst, dou { SCCOL nCols = 0; SCROW nRows = 0; - if (pMyFormulaCell) + // In JumpMatrix context use its dimensions for the return matrix; the + // formula cell range selected may differ, for example if the result is + // to be transposed. + if (pJumpMatrix) + { + SCSIZE nC, nR; + pJumpMatrix->GetDimensions( nC, nR); + nCols = std::max<SCCOL>(0, static_cast<SCCOL>(nC)); + nRows = std::max<SCROW>(0, static_cast<SCROW>(nR)); + } + else if (pMyFormulaCell) pMyFormulaCell->GetMatColsRows( nCols, nRows); if (nCols == 1 && nRows == 1) |