|
楼主 |
发表于 2018-9-24 12:32
|
显示全部楼层
本帖最后由 WYS67 于 2018-9-24 13:04 编辑
老师:把下面红色填充的If ac <> "" Then f = dr(ac, 0) Else f = "" 修改成 If ac <> "" And ac <=n Then f = dr(ac, 0) Else f = "" 后,E22:G27中,只是G22:G27单值公式的计算结果变成了空白,但E22:F27区域公式仍然显示0,没有显示空白:
Function DTJCX(aa As Range, a, ab As Range, b, ac As Range)
Application.Volatile
Dim ar, br, cr, dr, fr, f, i&, j&, k&, m&, n&
ar = aa: br = ab: cr = ac
For k = UBound(ar) To 1 Step -1
If ar(k, 1) <> "" Then Exit For
Next
ReDim dr(1 To k, 0): ReDim fr(1 To UBound(ar), 0)
For i = 1 To k
j = k - i + 1
If b = 0 Then
If ar(i, 1) <> "" And br(i, 1) <> "" And ar(i, 1) = a Then
n = n + 1: dr(n, 0) = br(i, 1)
End If
Else
If ar(j, 1) <> "" And br(j, 1) <> "" And ar(j, 1) = a Then
n = n + 1: dr(n, 0) = br(j, 1)
End If
End If
Next
If ac.Rows.Count > 1 Then
For i = 1 To UBound(ar)
If i >= cr(1, 1) And i <= cr(UBound(cr), 1) - cr(1, 1) + 1 Then
m = m + 1: fr(m, 0) = dr(i, 0)
Else: fr(i, 0) = ""
End If
Next
Else
If ac <> "" Then f = dr(ac, 0) Else f = ""
End If
If ac.Rows.Count > 1 Then DTJCX = fr Else DTJCX = f
End Function
|
|