Worksheet navigation

I am new to LibreOffice and pleased to be here. I have converted all my O365 workbooks to LO and they do what I need however I am now tackling ‘housekeeping’ issues, one of which is sheet navigation. All my workbooks are multisheet, each wsheet uses a horizontally split screen and many have a vertical split too. The sheets are split at varying rows and columns. To navigate there are 4 self explanatory movements Goto_Top, Goto_Bottom, Go_Up and Go_Down for incremental moves. I link each function to a button. Currently the incremental moves are limited to the visiblerange but I may wish to move to the top of tables instead.

The code below works for Go_Up and Go_Down, but only if I select a cell below the frozen row.
My question is how do I select a cell in that visiblerange?

Please bear in mind I may want to begin navigation half way down my data and go either way.
I do not want to select a cell outside of the visiblerange as this would cause a secondary jump.
And once a cell is selected in the lower pane it should not be repeated as that again would cause unecessary secondary jumps and possible screen flicker.

Dim nVisibleRows As Long

Function Get_First_Visible_Row
	Dim oDoc: oDoc = ThisComponent
	Dim oCtrl As Object: oCtrl= oDoc.CurrentController
	Dim aVisibleRange As New com.sun.star.table.CellRangeAddress
	aVisibleRange = oCtrl.getVisibleRange()
	nVisibleRows = aVisibleRange.EndRow - aVisibleRange.StartRow + 1
	Get_First_Visible_Row = aVisibleRange.StartRow
End Function

Sub Scroll_Down()
	Dim oDoc As Object: oDoc = ThisComponent
	Dim oCtrl As Object: oCtrl = oDoc.CurrentController
	oCtrl.FirstVisibleRow = Get_First_Visible_Row + nVisibleRows
End Sub

Sub Scroll_Up()
	Dim oDoc As Object: oDoc = ThisComponent
	Dim oCtrl As Object: oCtrl = oDoc.CurrentController
	oCtrl.FirstVisibleRow = Get_First_Visible_Row - nVisibleRows
End Sub

(Hope that turns out as intended)
Yes, I know I can do all this manually with the slider bar but that’s not what I want to do and often the slider is so small as to be almost useless. I have extensively experimented to get the freezerow of any given sheet and to establish if there are panes and other methods but all to no avail. I would very much appreciate a solution or pointers from more experienced LO users. As an aside, this was all easy peasy after 40 years in VBA but I am now a totally committed LO user and enjoying the new experience so far.

Version: 25.2.5.2 (X86_64) / LibreOffice Community
Build ID: 03d19516eb2e1dd5d4ccd751a0d6f35f35e08022
CPU threads: 20; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-AU (en_AU); UI: en-GB
Calc: CL threaded

like what ? :thinking:

How to freeze columns and rows in multiple sheets - #2 by fpy

Strictly speaking, VBA appeared in 1993 (and I’ve known it since then). :slight_smile:
I think, colleague, it would be worthwhile to upload a file in .ods format with your macros and explain what causes problems and in what cases.
Perhaps you will be interested in this topic.