Dim c As Range
Application.ScreenUpdating = False
For Each c In Range("G1", Range("G" & Rows.Count).End(xlUp))
If Left(c, 1) = "X" Then c = Mid(c, 2, Len(c) - 1)
If Left(c, 1) = "L" Then c = Mid(c, 2, Len(c) - 1)
If Left(c, 1) = "C" Then c = Mid(c, 2, Len(c) - 1)
Next c
Application.ScreenUpdating = True
如何在满足条件后让细胞改变内部颜色(让我们说浅蓝色)?
答案 0 :(得分:0)
已经内置了对条件格式的支持:https://support.office.com/en-us/article/Quick-start-Apply-conditional-formatting-6b6f7c2a-5d62-45a1-8f67-584a76776d67
无需重新发明轮子。
答案 1 :(得分:0)
使用:c.Interior.colorIndex = 8
可以找到颜色代码列表here。
修改强>
根据您的意见,完整的代码将是:
Dim c As Range
Application.ScreenUpdating = False
For Each c In Range("G1", Range("G" & Rows.Count).End(xlUp))
If Left(c, 1) = "X" Or Left(c, 1) = "L" Or Left(c, 1) = "C" Then
c = Mid(c, 2, Len(c) - 1)
c.Interior.ColorIndex = 8
End If
Next c
Application.ScreenUpdating = True