[Solved] Delete all blank cells and shift up
[Solved] Delete all blank cells and shift up
Is this possible?
Last edited by cul on Thu May 21, 2020 7:48 am, edited 1 time in total.
LibreOffice on Windows 7 (sometimes Mac)
Re: Delete all blank cells and shift up
The following macro selects all blanks within the current selection of cells:
With this selection you can delete rows.
Code: Select all
Sub SelectBlanks()
view = ThisComponent.getCurrentController()
x = view.Selection.queryEmptyCells()
view.select(x)
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Delete all blank cells and shift up
The multiselection allows to clear its cells from contents, but not to remove the cells from the sheet (filling columns up from the bottom). [Removal of complete rows or columns is supported.]
What the questioner asked for would be done by:
What the questioner asked for would be done by:
Code: Select all
Sub removeEmptyCellRangesFromActiveSheet() REM Very radical!
doc = ThisComponent
cCtrl = doc.CurrentController
sheet = cCtrl.ActiveSheet
cur = sheet.createCursor
cur.gotoStartOfUsedArea(False)
cur.gotoEndOfUsedArea(True)
curCols = cur.Columns
For Each col In curCols
eRgs = col.queryEmptyCells
u = eRgs.Count-1 REM Reverse order necessary!
For j = u To 0 Step - 1 REM Otherwise a new query needed before the next step!
sheet.removeRange(eRgs.RangeAddresses(j), 1)REM com.sun.star.sheet.CellDeleteMode.UP = 1
Next j
Next col
End Sub
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München