Well, I tried it. First with LibO V 6.1.1.3. Surprising result: No crash!
10000 rows with about 2500 runs of empty cells in column B.
The macro I thought would be rather efficient needed about 3 minutes.
The undo was a bit faster.
Using the Autofilter for column B in the same situation was fast with filtering, but needed also more than a minute to delete the due rows then. After undo the filter was messed up a bit.
OpenOffice did not accept GetCellRangeByName("B:B"). With the proper "correction" V4.1.5 was even a bit slower at the beginning, but seemed to work,
crashed finally, however. Filter not tested.
Code: Select all
Sub deleteRows(pEvent)
If NOT buttonSingleLeftClick(pEvent) Then Exit Sub
doc0 = ThisComponent
undoMgr = doc0.UndoManager
theSheet = doc0.CurrentController.ActiveSheet
colB = theSheet.getCellRangeByName("B:B") REM "B1:B1048576" for AOO.
bEmpty = colB.QueryEmptyCells
u = bEmpty.Count - 1
undoMgr.EnterUndoContext("Remove Rows")
For j = u To 0 Step -1
With bEmpty.RangeAddresses(j)
theSheet.Rows.RemoveByIndex(.StartRow, .EndRow - .StartRow + 1)
End With
Next j
undoMgr.LeaveUndoContext
End Sub
Function buttonSingleLeftClick(pEvent)
buttonSingleLeftClick = False
On Error Goto errorExit
If NOT pEvent.Source.SupportsService("com.sun.star.awt.UnoControlButton") Then Exit Function
With pEvent
IF NOT((.Modifiers=0) AND (.ClickCount=1) AND (.Buttons=1)) Then Exit Function
With .Source.Size
If NOT((pEvent.X>=0) AND (pEvent.X<=.Width) AND (pEvent.Y>=0) AND (pEvent.X>=.Height)) Then Exit Function
End With
End With
buttonSingleLeftClick = True
errorExit:
End Function
Use built-in interactive means.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München