Option Explicit Sub 按条件填色() Dim a, b, i, j a = Range("b1:b" & Cells(Rows.Count, "b").End(xlUp).Row) b = Array(7, 9, 0, 9) '个数不限自己修改 [b:b].Interior.ColorIndex = xlNone For i = 1 To UBound(a) - UBound(b) If a(i, 1) = b(0) Then For j = i + 1 To i + UBound(b) If a(j, 1) <> b(j - i) Then Exit For Next If j = i + UBound(b) + 1 Then Cells(i, "b").Resize(UBound(b) + 1).Interior.Color = vbYellow i = j - 1 End If End If Next End Sub