|
- Function SearchInWorkbook(ByVal Filename$, ByVal iCol&, ByVal iRow&, ByVal iValue&) As Long
- Dim wbname$, Path$
- Dim wb As Workbook
- Dim rg As Range
- Path = ThisWorkbook.Path & Application.PathSeparator & "表格" & Application.PathSeparator
- wbname = Dir(Path & Filename & ".*")
- If Len(wbname) = 0 Then SearchInWorkbook = 0: Exit Function
- Set wb = GetObject(Path & wbname)
- If wb Is Nothing Then SearchInWorkbook = 0: Exit Function
- With wb.Worksheets("Sheet1")
- Set rg = .Range(.Cells(1, iCol), .Cells(iRow, iCol)).Range.Find(iValue, , xlWhole, , , xlPrevious)
- 'Debug.Print rg.Address
- End With
- If rg Is Nothing Then
- SearchInWorkbook = 0
- Else
- SearchInWorkbook = rg.Row
- End If
- wb.Close False
- End Function
复制代码 |
|