我正试图将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 & "documentsappraiser_geniegenieold.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
任何帮助都将不胜感激!
用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
https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/dim-statement
声明多个变量您可以在一个声明语句中声明多个变量,为每个变量指定变量名,并在每个数组名后面加括号。多个变量用逗号分隔。VB
Dim lastTime,nextTime,allTime()As Date
不确定Dan Donoghue在说什么,但你可以用这种方式声明多个变量(见上面的链接)