我正在尝试将wb_和ws_variables传递给下面的函数getinfofromclosedfile,我继续在wb_name变量上得到一个byref参数不匹配。
Sub check_update()
Dim wb_path, wb_name, ws_name, ws_cell As String
AGuser = GetUser
If Dir("c:\users\" & AGuser & "\documents\appraiser_genie\genieold.xlsm") <> "" Then
wb_path = "c:\users\" & AGuser & "\documents\"
wb_name = "genieold.xlsm"
ws_name = "input"
ws_cell = Cells(17, 2).Address
Sheets("input").Cells(17, 2).Select = GetInfoFromClosedFile(wb_path, wb_name, ws_name, ws_cell)
End If
End Sub
Private Function GetInfoFromClosedFile(ByVal wbPath As String, _
wbName As String, wsName As String, cellRef As String) As Variant
任何帮助将不胜感激!
答案 0 :(得分:0)
使用ByVal
关键字声明参数:ByVal wbName As String, ByVal wsName As String
。
Function GetInfoFromClosedFile(ByVal wbPath As String, ByVal wbName As String, ByVal wsName As String, cellRef As String) As Variant
答案 1 :(得分:0)
https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/dim-statement
声明多个变量 您可以在一个声明语句中声明多个变量,为每个变量指定变量名称,并在每个数组名称后面加括号。多个变量用逗号分隔。 VB
Dim lastTime,nextTime,allTimes()As Date
不确定Dan Donoghue是关于什么的,但你可以用这种方式声明多个变量(见上面的链接)