Option Explicit
Sub CopyA1D1AndPasteToA6D6
CopyFromRangeA1D1AndPasteToRangeA6D6ByLooping(5)
End Sub
Sub CopyFromRangeA1D1AndPasteToRangeA6D6ByLooping(pRows&)
Dim oDoc As Object : oDoc = ThisComponent
Dim oSheet As Object : oSheet = oDoc.getCurrentController.ActiveSheet
Dim SourceRange, TargetCell As Object
' Dim TargetRange As Object
Dim i As Long
SourceRange = oSheet.getCellRangeByPosition(0, 0, 3, 0)
For i = 1 To pRows
TargetCell = oSheet.getCellByPosition(0, 0 + i)
' TargetRange = oSheet.getCellRangeByPosition(0, 0 + 1, 3, 0 + 1 + pRows - 1)
oSheet.copyRange(TargetCell.CellAddress, SourceRange.RangeAddress)
Next
End Sub
How can we avoid looping using i
and use TargetRange
for multiple rows instead?