Function GetLeave(empNo As String, strType As String)
Dim sht As Worksheet, rowFound As Long, colFound As Long, lgResult As Long
On Error Resume Next
For Each sht In ActiveWorkbook.Worksheets
If sht.Name <> "Summary" Then
rowFound = sht.Columns(2).Find(what:=empNo, after:=sht.Cells(1, 2), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Row
colFound = sht.Rows(9).Find(what:=strType, after:=sht.Cells(9, 1), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Column
If Err.Number = 0 Then
lgResult = lgResult + sht.Cells(rowFound, colFound)
Else
Err.Clear
End If
End If
Next
GetLeave = lgResult
End Function
|