Your suggestion results in the same difficulty. The row number does not increment by 1, nor should it iff FillMode is SIMPLE. I unfortunately cannot fine another FillMode which does what I want:
Cell C13
IF(OR(B13=0;ISFORMULA(D13));0;B13*D13*-1
Cell C14
IF(OR(B14=0;ISFORMULA(D14));0;B14*D14*-1
and so on
I was looking for a non-dispatcher way of doing what the below does which I can call after putting the formula into the R1 cell.
Sub FillRows(R1,R2) ’ Use a formula to fill rows R1 to R2
’ Currently selected cell is C1,R1 & the formula has been written to that cell
’ R2 is the last row to be filled
dim args1(0) as new com.sun.star.beans.PropertyValue
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)
args1(0).Name = “ToPoint”: args1(0).Value = R1
dispatcher.executeDispatch(oBook, “.uno:GoToCell”, “”, 0, args1())
args1(0).Name = “EndCell” : args1(0).Value = R2
dispatcher.executeDispatch(oBook, “.uno:AutoFill”, “”, 0, args1())
args1(0).Name = “ToPoint” : args1(0).Value = R1 & “:” & R2
dispatcher.executeDispatch(oBook, “.uno:GoToCell”, “”, 0, args1())
End Sub
What makes the Sub work is the uno:AutoFill