Page 1 of 1

[Solved] Macro to GOTO a Cell using Row:Column NUMBERS?

Posted: Mon Nov 26, 2012 8:16 pm
by alf50
Does anyone have an example Macro to GOTO a cell that I have just written a Number In. All the examples seem to use Row/Column ID's like A5, rather than the equivalent X,Y coordinates of the Cell (IE: 0,4)?

Re: Macro to GOTO a Cell using Row:Column NUMBERS?

Posted: Mon Nov 26, 2012 8:30 pm
by FJCC
There is a getCellByPosition() method. A macro would look like

Code: Select all

oSheets = ThisComponent.Sheets
oSheet = oSheets.getByName("Sheet1")
oCell = oSheet.getCellByPosition(0,4)
I'm not sure that you need to Go To (that is, select) that cell. There is no need to select the cell for most macro purposes.

Re: Macro to GOTO a Cell using Row:Column NUMBERS?

Posted: Mon Nov 26, 2012 10:54 pm
by JohnV
To have oCell become the active one add this line to FJCC's code.

Code: Select all

ThisComponent.CurrentController.Select(oCell)