学习日志
全民一起VBA提高篇
第五回 逻辑终将分真伪 判断实则看是非
相关知识点
dim a as boolean
城市涂色
Option Explicit
Sub paintcities()
Dim paint As Boolean, i&
paint = False
i = 4
Do While Trim(Cells(i, 2)) <> ""
If LCase(Trim(Cells(i, 2))) <> LCase(Trim(Cells(i - 1, 2))) Then
paint = Not paint
End If
If paint Then
Range(Cells(i, 2), Cells(i, 4)).Interior.Color = RGB(0, 0, 255)
End If
i = i + 1
Loop
End Sub