Skip to content

Instantly share code, notes, and snippets.

@precious
Created January 30, 2012 20:18
Show Gist options
  • Save precious/1706425 to your computer and use it in GitHub Desktop.
Save precious/1706425 to your computer and use it in GitHub Desktop.
REM ***** BASIC *****
Option Explicit
Sub Main
Dim oDocument
Dim oSelectedCells
Dim oActiveCells
Dim oSheet
Dim oTargetCell
Dim nRow
Dim nCol
Dim dValue
oDocument = ThisComponent
oSelectedCells = oDocument.CurrentSelection
oActiveCells = oSelectedCells.RangeAddress
oSheet = oDocument.Sheets.getByIndex(oActiveCells.Sheet) ' active table
oTargetCell = oSheet.getCellByPosition(oActiveCells.StartColumn,oActiveCells.StartRow)
' excluding first row which contains target cell
For nRow = oActiveCells.StartRow + 1 To oActiveCells.EndRow
For nCol = oActiveCells.StartColumn To oActiveCells.EndColumn
dValue = oTargetCell.getValue()
oSheet.getCellByPosition(nCol,nRow).setValue(dValue)
oDocument.calculate()
Next
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment