|
发表于 2014-5-22 11:05
|
显示全部楼层
本楼为最佳答案
请看附件。附件里代码略有改动,考虑了最大列的边界问题。- Sub tt()
- Range("ag:ag").ClearContents
- arr = [a1].CurrentRegion
- For i = 2 To UBound(arr)
- xstr = "": n = 0: s = 0
- For j = 1 To UBound(arr, 2)
- x = Left(arr(i, j), 1)
- If InStr("ABC", x) > 0 And Len(x) > 0 Then
- s = s + 1
- Else
- If s >= 7 Then
- n = n + 1
- xstr = xstr & "," & Cells(i, j - 1).Address
- End If
- s = 0
- End If
- If j = UBound(arr, 2) And s >= 7 Then
- n = n + 1
- xstr = xstr & "," & Cells(i, j).Address
- End If
- Next
- If n > 0 Then
- Cells(i, "ag") = "已有" & n & "次超出7天,是" & Mid(Replace(xstr, "$", ""), 2)
- Else
- Cells(i, "ag") = "无"
- End If
- Next
- End Sub
复制代码 |
|