问题:我需要在已关闭的工作簿中搜索特定值,然后返回匹配字符串的行号,或者更优选地返回具有匹配字符串行号的值。
我试图让它与该ExecuteExcel4Macro
功能一起使用,我的代码可以在下面找到。
Private Function GetInfoFromClosedFile2(ByVal wbPath As String, ByVal wbName As String, ByVal wsName As String, ByVal colNum As Integer, ByVal searchString As String) As Variant
Dim arg As String
GetInfoFromClosedFile2 = vbNullString
If Right(wbPath, 1) <> "\" Then wbPath = wbPath & "\"
If Dir(wbPath & wbName) = vbNullString Then Exit Function
arg = "'" & wbPath & "[" & wbName & "]" & wsName & "'!" & Worksheets(wsName).Columns(colNum).Find(What:=searchString).Address(True, True, xlR1C1)
'On Error Resume Next
GetInfoFromClosedFile2 = ExecuteExcel4Macro(arg)
End Function
arg =
我在线上收到运行时错误“9”