Public Sub addtoMA(dbPrice As Double, dbRow As Double, sh As Worksheet)
Dim s As Long 'for bitshifting the array
Const colstosave = 50
Dim rn As Range, intPrice() As Variant
deActsheet 'stop events and other annoyance
On Error GoTo catch
If dbRow = 0 Then
'MsgBox "row number missing in addtoma"
GoTo finally
End If
Set rn = sh.Range("At" & dbRow & ":cQ" & dbRow) 'the row
intPrice() = rn 'the array
' shift elements one position right- e.g. arr 99 moves to arr 100
For s = colstosave To 2 Step -1
If intPrice(1, s - 1) <> "" Then
intPrice(1, s) = intPrice(1, s - 1)
Else
intPrice(1, s) = 0
End If
Next s
intPrice(1, 1) = dbPrice 'current price
rn = intPrice() 'store the array
finally:
Set rn = Nothing
actSheet 'allow events and other annoyance
Exit Sub
catch:
'MsgBox Err.Description
Debug.Print ""
GoTo finally
End Sub
当我使用以下命令从立即窗口调用时,上面的代码运行完美: addtoMA 5,9,sheetpointer
在集成中,由作为公式嵌入的函数调用。
接收到的参数是相同的,我对此进行了仔细检查。
rn.rows
和rn.columns.count
的尺寸与
ubound(intprice,1)
和ubound(intprice,2
)
但是每次从表单中调用时都会失败
应用程序定义或对象定义的错误
我只能使用数据库,但是我不能被它击败。
有什么想法吗? 它只会为机器人生成一些移动平均值