"Offset" in LibreOffice Calc macro

I’m working to create a macro to count some subjects (I’m a school secretary). Btw, my macros are extremely poor and simple, considering that I’m still learning (by miself). The trouble I’m having is: To the macro work the way I want, I need something like the “ActiveCell.Offset(1,0).Select” that works on VBA (Excel). But I can’t find nothing that do the same as the offset.
Is there something to do? (Sorry my bad english, Brasilian person here).

In VBA the ActiveCell should be expected to be the cell currently having the focus for keyboard input.
In Calc you can have a ThisComponent.CurrentSelection (cells highlighted in the view) and at the same time a cell having the focus, but not being highlighted.
Do you actually want to assure that your “active cell” is a single-cell-selection? This is what @KamilLanda obviously assumed.
If you describe what you want to achieve to more detail, we might suggest a way to do it more efficiently with native means of LibreOffice (Basic / API). “Thinking VBA” you will often be mislead concerning Calc.

Sub cellOffsetSelect
	dim oDoc as object, oSel as object, oActiveCell as object, oCell as object, iSheet&, iColumn&, iRow&
	oDoc=ThisComponent
	oSel=oDoc.CurrentController.getSelection 'current selection
	if oSel.supportsService ("com.sun.star.sheet.SheetCell") then 'only one cell is selected
		oActiveCell=oSel
	else
		exit sub
	end if
	iSheet=oActiveCell.CellAddress.Sheet 'number of current sheet
	iColumn=oActiveCell.CellAddress.Column 'number of current column
	iRow=oActiveCell.CellAddress.Row 'number of current row
	oCell=oDoc.sheets(iSheet).getCellByPosition(iColumn+1, iRow+0) 'OFFSET: +1 for the column, +0 for the row
	oDoc.CurrentController.Select(oCell) 'select new cell
End Sub
1 Like

Thank you! That is exactly what I needed.