【发布时间】:2016-08-30 12:38:34
【问题描述】:
我在 LibreOffice Calc 中编写了一个宏,它能够正确运行。但是如果我关闭文件并重新打开,它总是显示#NULL! 而不是正确的值。我在这里错过了什么?
我的宏代码
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Function Calculate(CalType As String) As Double
'
' Calculate Macro
'
Dim i As Integer
Calc = 0
i = 1
Do While Not IsEmpty(Cells(i, 2))
If (Cells(i, 3).Value = CalType And (Cells(i,2) = "A" Or Cells(i,2) = "B")) Then
Calculate = Calculate + Cells(i, 4).Value
ElseIf (Cells(i, 3).Value = CalType And Cells(i,2) = "C") Then
Calculate = Calculate - Cells(i, 4).Value
End If
i = i + 1
Loop
'
End Function
调用函数类似于=Calculate(J6)
文件保存为.ods格式。
【问题讨论】:
-
请提供一个显示问题的示例宏。另外,您使用的是 .ods 格式吗?
-
我已经添加了我的宏代码。
标签: macros libreoffice