Is there a possibility to get current topmost row shown via macro in calc?

Hi there,

is there any way to get the currently first row shown at display determined via macro?
If so - how can this be done?

Thank you in advance!


If I understand what you mean, the code below selects first row and colors it with gray.

Sub ColorFirstRow
 Dim firstRow
 firstRow = ThisComponent.Sheets.getByIndex(0).Rows(0)
 firstRow.CellBackColor = RGB(225, 225, 225)
End Sub

Thank you. Unfortunately this only seems to work as long as no other row is selected. As soon as another row is clicked that one gets selected by this code.

Is there also a way to get the current visible topmost row regardless which other row might be selected?

I just made changes to third line. Please let me know if it suits or not what you are looking for.

This will always select the row with index 0 - regardless whether it is displayed or not.
I am looking for something which shows me the first (well better second since I froze first line) currently visible row! So if let’s say currently row 0 is topmost row visible I want to determine 0, if I now scroll down entire sheet for 10 lines I want to get 10, after scrolling down another 8 lines I want to get 18 - and so on and so forth; same for scrolling up again).