Since the topic meanwhile got >1 kView a task of the kind seems to occur frequently.
I therefore now post user code for it also covering cases where the “guidecolumn” may contain empty cells or is not adjacent to the new column(s).
The source range (your new formulas e.g.) may be any single range (more than one column e.g, if more than one row to the same effect as if you do an autofill by Ctrl+Drag).
To avoid nasty surprises the action will only be carried out if the range to get filled has no true content (number, date, text, formula) in advance. Anchored objects -including annotations- remain untouched.
The target range extends down to the end of the “used area” of the sheet. The term includes cells with ‘different attributes’, (I have to admit that I don’t know an exact specification for the term “used area”. Play with Ctrl+End to check yourselft.)
Sub fillDownForUsedAreaRows(Optional pSourceRange As Object)
REM The Sub creates as a single undo step.
REM Formatting in the fillRange will be replaced by formatting of the sourceRange!
If IsMissing(pSourceRange) Then pSourceRange = ThisComponent.CurrentSelection
If NOT pSourceRange.supportsService("com.sun.star.sheet.SheetCellRange") Then Exit Sub
sourceLength = pSourceRange.Rows.Count
sheet = pSourceRange.Spreadsheet
sheetCur = sheet.CreateCursor()
sheetCur.gotoEndOfUsedArea(False)
uaEndRow = sheetCur.RangeAddress.EndRow
With pSourceRange.RangeAddress
If (.EndRow>uaEndRow) OR (uaEndRow=sheet.RangeAddress.endRow) Then Exit Sub
fillRange = sheet.getCellRangeByPosition(.StartColumn, .EndRow + 1, .EndColumn, uaEndRow)
check = fillRange.queryContentCells(23) REM = number(1)+Date(2)+string(4)+formula(16)
If check.Count>0 Then Exit Sub
fillRange = sheet.getCellRangeByPosition(.StartColumn, .StartRow, .EndColumn, uaEndRow)
End With
fillRange.fillAuto(0, sourceLength) REM 0 = com.sun.star.sheet.FillDirection.TO_BOTTOM
End Sub