|
nixliu 发表于 2016-6-14 16:04
谢谢啊
麻烦问下 如果改成 A列 B列 都需要侦测 要怎样改写? - Sub xx()
- Dim n&, n1&
- With Sheet1
- Set rng = .Columns("A:B")
- n = .Cells(.Rows.Count, 1).End(xlUp).Row
- n1 = .Cells(.Rows.Count, 2).End(xlUp).Row
- .Cells.Interior.ColorIndex = 0
- For i = 1 To n
- If InStr(.Cells(i, 1), "村") + InStr(.Cells(i, 1), "乡") > 0 Then .Cells(i, 1).Interior.ColorIndex = 4
- Next
- For i = 1 To n1
- If InStr(.Cells(i, 2), "村") + InStr(.Cells(i, 2), "乡") > 0 Then .Cells(i, 2).Interior.ColorIndex = 4
- Next
- End With
- End Sub
复制代码 |
|