copy the value of a cell not the formula inside of it

Hello to all,
i am using a macro that helps me to copy values from a cell and paste it into another cell, the number of the target cell is obtained from the value of another cell. the problem i am facing with the macro i am using, is that the macro in some cases ( in the sourceRange in the code below ) is copying the formula inside the cell and not the value obtained from the formula. so what i need exactly is to copy the visible values not the formulas.

this is the macro that i am using:

Sub commandButton2_Click_nativeLibreOfficeBasicWithAPI
theSheet    = ThisComponent.Sheets.getByName("Sheet1")
sourceRange = theSheet.getCellRangeByName("K10")
paramCell   = theSheet.getCellRangeByName("K6")
targetCell  = theSheet.getCellRangeByName(paramCell.String)
theSheet.CopyRange(targetCell.CellAddress, sourceRange.RangeAddress)
End Sub

And what to use the property .string or .value?


Or also methods .getDataArray / .setDataArray

Did you try using Paste Special?