Function pduan(a, b, c As Range) As Variant
Dim aa, bb, cc, e
aa = 0
bb = 0
cc = 0
If a <> "" And Abs(a - 7.5) > 1.5 Then aa = Abs(a - 7.5)
If b <> "" And Abs(b - 7.5) > 1.5 Then bb = Abs(b - 7.5)
If c <> "" And Abs(c - 7.5) > 1.5 Then cc = Abs(c - 7.5)
If aa <> 0 Or bb <> 0 Or cc <> 0 Then
e = WorksheetFunction.Max(aa, bb, cc)
If e = aa Then pduan = a
If e = bb Then pduan = b
If e = cc Then pduan = c
Else
pduan = ""
End If
End Function
插入一个模块,把上面的函数复制进去,然后你在D1单元格输入"=pduan(A1,B1,C1)",下拉填充,就可以了,请试一试吧,祝你顺利!
如果数据在A1:C1中,D1中输入
=INDEX(A1:C1,MATCH(MAX(IF(A1:C1<>"",ABS(A1:C1-7.5))),IF(A1:C1<>"",ABS(A1:C1-7.5)),))
同时按下CTRL+SHIFT+ENTER输入数组公式,如果A1:C1下面还有类似数据,用自动填充柄将D1中的公式向下复制。
=IF(ABS(IF(ABS(ABS(A1)-7.5)>ABS(ABS(B1)-7.5),A1,IF(ABS(ABS(B1)-7.5)>ABS(ABS(C1)-7.5),B1,C1))-7.5)>1.5,IF(ABS(ABS(A1)-7.5)>ABS(ABS(B1)-7.5),A1,IF(ABS(ABS(B1)-7.5)>ABS(ABS(C1)-7.5),B1,C1)),"")
=IF(OR(A1=0,B1=0,C1=0),0,……),前面加一个这样的IF判断行不?
判断是否有空白isbalnk()函数
加if判断