|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub MarkConsecutiveNonEmptyValues() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Sheet1") Dim lastRow As Long lastRow = ws.Cells(ws.Rows.count, "G").End(xlUp).Row Dim i As Long For i = 1 To lastRow - 2 If Not IsEmpty(ws.Cells(i, "G").Value) And _ ws.Cells(i, "G").Value = ws.Cells(i + 1, "G").Value And _ ws.Cells(i, "G").Value = ws.Cells(i + 2, "G").Value Then ws.Cells(i, "G").Interior.Color = RGB(0, 0, 255) ws.Cells(i + 1, "G").Interior.Color = RGB(0, 0, 255) ws.Cells(i + 2, "G").Interior.Color = RGB(0, 0, 255) End If If Not IsEmpty(ws.Cells(i, "H").Value) And _ ws.Cells(i, "H").Value = ws.Cells(i + 1, "H").Value And _ ws.Cells(i, "H").Value = ws.Cells(i + 2, "H").Value Then ws.Cells(i, "H").Interior.Color = RGB(0, 0, 255) ws.Cells(i + 1, "H").Interior.Color = RGB(0, 0, 255) ws.Cells(i + 2, "H").Interior.Color = RGB(0, 0, 255) End If If Not IsEmpty(ws.Cells(i, "I").Value) And _ ws.Cells(i, "I").Value = ws.Cells(i + 1, "I").Value And _ ws.Cells(i, "I").Value = ws.Cells(i + 2, "I").Value Then ws.Cells(i, "I").Interior.Color = RGB(0, 0, 255) ws.Cells(i + 1, "I").Interior.Color = RGB(0, 0, 255) ws.Cells(i + 2, "I").Interior.Color = RGB(0, 0, 255) End If Next i End Sub |
|