4

So I have a macro to clear some cells A2-A250 but I want to return to cell A1 once I have finished

Sub reset
Dim oActiveSheet As Variant
Dim oCellRangeByName As Variant

oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()

oCellRangeByName = oActiveSheet.getCellRangeByName("A1:A250")

oCellRangeByName.clearContents(7)
End Sub
moggi
  • 1,466
  • 4
  • 18
  • 29
OliverH
  • 61
  • 1
  • 3

1 Answers1

3

To move to a cell, select it:

oRange = oActiveSheet.getCellRangeByName("A1")
ThisComponent.getCurrentController().Select(oRange)

Section 6.5.3 of Andrew Pitonyak's macro document discusses how to select a cell with or without the outline. Add this code to unhighlight the cell:

oRanges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
ThisComponent.getCurrentController().Select(oRanges)
Jim K
  • 12,824
  • 2
  • 22
  • 51