|
楼主 |
发表于 2018-12-19 14:30
|
显示全部楼层
本帖最后由 WYS67 于 2018-12-19 18:09 编辑
老师:实际应用时,发现两个问题:1.如上图所示,各列公式显示的计算结果,最后一个三位数有时会出现【还有时候显示的结果正确】遗漏数据的情况。就是如上面截图的,在C:I列显示的计算结果最后,找不到A3542:A3544三个数连接的结果350.
2.这个函数的代码,在计算过程中很卡。
多条件上下连接数据 - 副本.zip
(1.25 MB, 下载次数: 8)
代码
Function SSLJ(rn As Range, a, Optional b = "")
Dim ar, br, cr, dr, c%, d&, i&, j&, m&, n&, x&, y&
Application.Volatile
ar = rn: x = Application.Count(rn)
c = (x - 2) Mod 3: d = Int(x / 3)
For j = UBound(ar) To 1 Step -1
If ar(j, 1) <> "" Then Exit For
Next
ReDim br(1 To j, 0): ReDim cr(1 To UBound(ar), 0): ReDim dr(1 To UBound(ar), 0)
For i = 1 To j
If ar(i, 1) <> "" Then y = y + 1: br(y, 0) = ar(i, 1)
Next
For i = 1 To UBound(ar)
m = i * 3 + c
If i < d Then cr(i, 0) = br(m - 2, 0) & br(m - 1, 0) & br(m, 0) Else: cr(i, 0) = ""
If b <> 0 And b <> "" Then
n = b - d - 3
If i > n And i < b - 3 Then dr(i, 0) = cr(i - n, 0) Else: dr(i, 0) = ""
End If
Next
If a = 1 And (b = 0 Or b = "") Then cr(d, 0) = br(x - 1, 0) & br(x, 0)
If a = 1 And b <> 0 And b <> "" Then dr(b - 3, 0) = br(x - 1, 0) & br(x, 0)
If b = 0 Or b = "" Then SSLJ = cr
If b <> 0 And b <> "" Then SSLJ = dr
End Function
恳请老师看看是不是代码里少显示了最后一行结果;怎样才能使代码计算时不卡?
坐等急用!恳请老师帮忙!
|
|