請再測試看看,謝謝
Sub test()
Dim Arr, xU, s%
Arr = [a1].CurrentRegion
Set xU = [a3]
For i = 3 To UBound(Arr)
For j = 3 To UBound(Arr, 2)
If Arr(i, j) Like "*班" Or Arr(i, j) Like "[A-z]*[0-9]" Or Arr(i, j) Like "[A-z]*" Or Arr(i, j) Like "[0-9]*" Then
s = s + 1: Set xU = Union(xU, Cells(i, j))
If s > 6 Then xU.Interior.ColorIndex = 45: Cells(i, 2).Interior.ColorIndex = 3
Else
s = 0: Set xU = Nothing: Set xU = [a3]
End If
Next
s = 0: Set xU = Nothing: Set xU = [a3]
Next
[a3].Interior.ColorIndex = xlNone
End Sub