试试这段代码:
Sub bd()
Dim Sh As Worksheet
Application.ScreenUpdating = False
For Each Sh In Worksheets
For i = 1 To Sh.[D65536].End(xlUp).Row
If Sh.Cells(i, 4) <> "" And Sh.Range("IV" & i).End(xlToLeft).Column > 4 Then
For f = 5 To Sh.Range("IV" & i).End(xlToLeft).Column
If Sh.Cells(i, 4) - Sh.Cells(i, f) = 17 Or Sh.Cells(i, 4) - Sh.Cells(i, f) = -17 Then
Sh.Cells(i, 4).Interior.ColorIndex = 6
Sh.Cells(i, f).Interior.ColorIndex = 6
End If
Next
End If
Next
Next
Application.ScreenUpdating = True
End Sub |