Sub test()
Dim MySht As Worksheet
Dim MyRng As Range
Set MySht = ThisWorkbook.Sheets("Sheet1")
Set MyRng = MySht.UsedRange.Columns("C")
For Each cell In MyRng.Cells
If Not cell = "test" Then
cell.Interior.ColorIndex = 4
End If
Next
End Sub
答案 0 :(得分:3)
如果我理解你的问题,你想跳过范围的第1行。在这种情况下,您可以按如下方式修改for循环:
For Each cell In MyRng.Cells
If cell.Row != 1 Then
If Not cell = "test" Then
cell.Interior.ColorIndex = 4
End If
End If
Next