我正在尝试编写一个VBA宏,它通过计算直接在其上方和下方的单元格的平均值,将值分配给特定单元格。我通过选择开发工具栏上的宏按钮来运行它,然后我必须键入我的函数的名称(它不会出现在列表中)“interpprob”并选择运行。然后我得到一个弹出窗口,其中指出“参数不是可选的”。我不太确定问题是什么。完整的宏在下面。 “tstep”意味着需要更改一些单元格值的一组行的数组。VBA“参数不可选” - 不确定如何声明变量
Function interpprob(f As Integer, d As Integer, spec As String, tstep As Long, above As Long, below As Long, i As Integer, j As Integer)
f = 41
d = 441
spec = ETHA
tstep(0) = f
tstep(1) = f + d
tstep(2) = f + 2 * d
tstep(3) = f + 5 * d
For i = 0 To 4
For j = 52 To 57
above = Cells(tstep(i) - 1, j).Value
below = Cells(tstep(i) + 1, j).Value
Sheets(spec).Cells(tstep(i), j).Value = (above + below)/2
Next j
Next i
End Function
感谢, BL袋鼠
确保您使用全部8个参数调用'interpprob'。 – miroxlav
这将如何完成?只需输入“interpprob(f,d,spec,tstep,above,below,i,j)”? –
您需要实际值(参数)来代替这8个参数。你有什么想法,你会把'f','d','spec'等放在什么位置? – miroxlav