这个标准函数很难实现吧。我用vba写个自定义函数来解决吧。
代码如下:
Function fmBJ(S1, S2) As Integer
'比较S1和S2的大小
'S1>S2 返回2 S1=S2 返回1 S1<S2 返回0
Dim fs1 As Integer
Dim fs2 As Integer
Dim ms1 As Integer
Dim ms2 As Integer
fs1 = Left(S1, 2)
fs2 = Left(S2, 2)
ms1 = Mid(S1, 4, 2)
ms2 = Mid(S2, 4, 2)
If fs1 = fs2 And ms1 = ms2 Then
fmBJ = 1
Exit Function
Else
Select Case fs1 - fs2
Case Is > 0
fmBJ = 2
Case Is = 0
If ms1 > ms2 Then
fmBJ = 2
Else
fmBJ = 0
End If
Case Is < 0
fmBJ = 0
End Select
End If
End Function
Function pbFs(nl, fm) As Integer
Dim Ls As Integer
Dim Hs As Integer
Dim bJ As Boolean
Dim BJJG As Integer
Select Case nl
Case Is <= 24
Ls = 2
Case 25 To 28
Ls = 3
Case 29 To 31
Ls = 4
Case 32 To 34
Ls = 5
Case 35 To 37
Ls = 6
Case Is >= 38
Ls = 7
End Select
bJ = False
For I = 2 To 10
S1 = Cells(I, Ls).Text
BJJG = fmBJ(S1, fm)
If BJJG <> 0 Then
bJ = True
Exit For
End If
Next I
If bJ Then
pbFs = Cells(I, 1).Value
Else
pbFs = 0
End If
End Function
结果如图: