|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST4()
Dim ar, br, cr, vResult, i&, j&, k&, n&, strJoin$, t#
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
ar = Range("A1", Cells(Rows.Count, "A").End(xlUp)).Value
br = Range("H1:H3").Value
ReDim cr(2)
ReDim vResult(1 To UBound(ar) - 2, 1 To 18)
For i = 1 To UBound(ar) - 2
For j = 1 To UBound(vResult, 2)
For k = 0 To 2
cr(k) = ar(i + k, 1) + j
cr(k) = IIf(cr(k) > 18, cr(k) - 18, cr(k))
Next k
n = 0
strJoin = "," & Join(cr, ",") & ","
For k = 1 To UBound(br)
If InStr(strJoin, "," & br(k, 1) & ",") Then n = n + 1
Next k
vResult(i, j) = n
Next j
Next i
[K1].Resize(UBound(vResult), UBound(vResult, 2)) = vResult
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "执行完毕!_用时: " & Format(Timer - t, "0.00") & " 秒", 64
End Sub |
评分
-
1
查看全部评分
-
|