测试PEL公式Formula1
DM1:"CF01$close"; {DM-商品代码简称}
DM2:"CF09$close";
运行正常。
希望用自定义函数从窗体中取得两个代码的变量BL1,BL2
窗体文件运行正常,代码如下:
Sub UserForm2_Load()
UserForm2_TextBox1.value="CF01"
UserForm2_TextBox2.value="CF09"
End Sub
自定义函数代码如下:
Function userform2(Formula,BL1,BL2)
IF UserForm2_TextBox1.value<>"" then
BL1=userform2_Textbox1.value
End If
IF UserForm2_TextBox2.value<>"" then
BL2=userform2_Textbox2.value
End If
End Function
将函数,BL1,BL2 带入PEL公式Formula1
DM1:"BL1$close"; {DM-商品代码简称}
DM2:"BL2$close";
点击“编译公式F” 显示“测试正常”。
然后运行窗体,查看窗格中公式Formula1, 没有任何数据显示,敬请老师指导。
另用宏方式测试Function 代码运行情况:代码正常:
Sub KKK()
IF UserForm2_TextBox1.value<>"" then
BL1=userform2_Textbox1.value
End If
IF UserForm2_TextBox2.value<>"" then
BL2=userform2_Textbox2.value
End If
msgbox BL1 & BL2 ‘输出正常
End Sub
用APPLICATION.MSGOUT 函数,在自定义函数中看看输出就知道了。
此外金字塔的自定义函数不支持字符串的传递。
你只能考虑用全局变量数据库来进行传递。