'g列的数值不知道怎么来的。
'都是文字题,本来跑这里来是学VBA的,不过现在发现我的理解能力真的很差,很多问题竟然都看不懂!
'球赛马上要开始了,反正就这方法自己修改。
Option Explicit
Sub test()
Dim i, arr, s1, s2, j, a, n
arr = Range("c3:e" & Cells(Rows.Count, "c").End(xlUp).Row)
s1 = [i1].Value: s2 = [j1].Value
For i = 1 To UBound(arr, 1)
arr(i, 1) = IIf((InStr(s1, arr(i, 1)) > 0 Or InStr(s1, arr(i, 2)) > 0 Or InStr(s1, arr(i, 3)) > 0) And (InStr(s2, arr(i, 1)) > 0 Or InStr(s2, arr(i, 2)) > 0 Or InStr(s2, arr(i, 3)) > 0), 1, vbNullString)
Next
[f3].Resize(UBound(arr, 1)) = arr '写入f列
arr = Range("f3:f" & Cells(Rows.Count, "f").End(xlUp).Row + 1)
ReDim brr(1 To UBound(arr, 1), 1 To 1)
For i = 1 To UBound(arr, 1) - 1
For j = i To UBound(arr, 1) - 1
If Len(arr(j, 1)) > 0 Then a = j: Exit For
Next
For j = a To UBound(arr, 1) - 1
If Len(arr(j + 1, 1)) = 0 Then
n = n + 1: brr(a, 1) = j - a + 1
i = j: Exit For
End If
Next j, i
' For i = 1 To Int(UBound(arr, 1) / 2)
' a = brr(i, 1)
' brr(i, 1) = brr(UBound(brr, 1) - i + 1, 1): brr(UBound(brr, 1) - i + 1, 1) = a
' Next
With [i3] '连续统计,写入i列
.Resize(Rows.Count - 2).ClearContents
.Resize(n) = brr
End With
End Sub |