如何在开放式办公室中拖拽复杂的计算。

如何在开放式办公室中拖拽复杂的计算。

例如,如果 A1 包含 30 而在 A2 中写入,=A1-6那么我将在 A2 中得到 27,如果我单击 A2 右下角的小黑色方块并将其向下拖动,那么我将得到如下列:

30
27
24
21
18
15
12

等等。

但是,如果我尝试使用多个变量的公式来执行此操作,则它将不起作用。例如,如果我输入 A2= (A1 - B1)*C1并以相同方式将其向下拖动,则下一个单元格将具有公式= (A2 - B2)*C2。但我只希望 A# 增加。

我该怎么做呢?

答案1

字母(列)或数字(行)前的“$”将阻止其自动递增。“$a$2”永远不会递增。“a$2”列只会递增。“$a2”行只会递增

type in A2 = (A1 - B1)*C1
 I only want the A# to get incremented
        a2 = ($a1-$b$1)*$c$1

答案2

这是一个给你的宏:

REM  *****  BASIC  *****

Sub Main


End Sub


sub arg
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$4"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "StringName"
args2(0).Value = "30"


dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args2())
dim args4(0) as new com.sun.star.beans.PropertyValue

for a=0 to 100
args1(0).Name="ToPoint"
args1(0).Value="a"+(a+4)

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:JumpToNextCell", "", 0, Array())

rem ----------------------------------------------------------------------

args4(0).Name = "StringName"
args4(0).Value = "="&30-(3*a)


dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args4())
next a
rem ----------------------------------------------------------------------

end sub

相关内容