[Solved] [Calc] Delete Entire Row Content
Posted: Thu Dec 07, 2023 6:29 pm
I have the following macro to delete entire row(s) based on cell value of that specific row...
I would like the macro to be altered to DELETE ROW CONTENT only.
I'm guessing this is the line that needs altered, but i'm unsure how..
oRows.removeByIndex(nRow,1)
Ive tried:
oRows.RemoveContent(nRow,1)
oRows.ClearContent(nRow,1)
Rows.ClearContent(nCells,1)
without success.
Any ideas / fast fixes??
..Im Debian 12 with LO 7.5.8
Code: Select all
Sub DeleteRows
oSheet=thiscomponent.getcurrentcontroller.activesheet
rem This routine assumes a single column range contains the values to be checked for row deletion
oRange = oSheet.GetCellRangeByName("N1:N118")
oRows = ThisComponent.CurrentController.ActiveSheet.Rows
nStartRow = oRange.getRangeAddress.StartRow
nEndRow = oRange.getRangeAddress.EndRow
nCol = oRange.getRangeAddress.StartColumn
for nRow = nStartRow to nEndRow
rem The next line specifies the cell to be checked
oCell = oSheet.GetCellByPosition(nCol,nRow)
rem The next line specifies a value qualifying the row for deletion
if oCell.GetString = "delete this row" then
Count = Count + 1
oRows.removeByIndex(nRow,1) 'the second argument limits deletion to 1 row at a time
End if
next
MsgBox Count & " rows deleted"
End Sub
I'm guessing this is the line that needs altered, but i'm unsure how..
oRows.removeByIndex(nRow,1)
Ive tried:
oRows.RemoveContent(nRow,1)
oRows.ClearContent(nRow,1)
Rows.ClearContent(nCells,1)
without success.
Any ideas / fast fixes??
..Im Debian 12 with LO 7.5.8