How to move up 1 row if there are hidden rows (IsVisible = False)?

If you use the UNO method, then according to the example below. And if you use the API?
By the way, what does the Sel parameter mean in the “.uno:GoUp” method?

Sub UnoGoUp()
'''	Go up 1 row skipping invisible rows.
''' Called by: DeleteCurrent

	Dim document As Object, dispatcher As Object

	document = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

	Dim args(1) As New com.sun.star.beans.PropertyValue
	args(0).Name = "By"
	args(0).Value = 1
	args(1).Name = "Sel"
	args(1).Value = False

	dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args())
End Sub

It is necessary if the last record has been deleted. Otherwise we will be out of range.

Expand the Selection (True) or not (False)

btw. I thought you were a programmer and not a recorder!

Thanks
I’m not a programmer in the literal sense, if that’s what you mean.
I know about the .queryVisibleCells method. But how to go up quickly.
Снимок экрана от 2021-11-22 14-35-22

Maybe,
nRow = oRanges(oRanges.Count - 1).RangeAddress.EndRow ? Not tested.
UPDATED:
Yes it works.
However, the new cell needs to be calculated and then activated. But uno:GoUp did both.

pardon… python!

doc =XSCRIPTCONTEXT.getDocument()
sel = doc.CurrentSelection
sheet = sel.Spreadsheet
cursor = sheet.createCursorByRange(sel)
while True:
    cursor.gotoOffset(0,-1)
    if cursor.Rows.IsVisible:
        break
print(cursor.Rows.IsVisible)
1 Like

@karolus , thanks. It’s even better. I know Python.