简体   繁体   English

如何根据另一个单元格值突出显示单元格值

[英]how to Highlight cells value based on another cells value

I'm working on a macro that highlighted & colors the empty cells in a specific column (AE), but I need to clear this color-highlighted based on a result that exists in the column (AD)我正在研究一个突出显示&colors特定列(AE)中的空单元格的宏,但我需要根据列(AD)中存在的结果清除此颜色突出显示

If AD column, cells value = "SPLICE" clear color, If Empty the color should exist, below picture explains more.如果 AD 列,单元格 value = "SPLICE" 清除颜色,如果为 Empty,颜色应该存在,下图解释更多。 I use the code below我使用下面的代码

Sub EmptyTerminalTO()

Application.ScreenUpdating = False

Sheets("Wire List").Activate
Dim i As Long
Dim c As Long
Dim myRange As Range
Dim myCell As Range

Set myRange = Range("AD2", Range("AD" & Rows.Count).End(xlUp))

For Each myCell In myRange '
    c = c + 1
    If (myCell) = "" Then
        myCell.Interior.Color = RGB(255, 87, 87)
        i = i + 1
    End If
Next myCell

Rapport8 = i

 Application.ScreenUpdating = True
 
End Sub

在此处输入图像描述

try using offset as per code below:尝试按照以下代码使用偏移量:

Option Explicit

Sub EmptyTerminalTO()

Application.ScreenUpdating = False

Sheets("Wire List").Activate
Dim i As Long
Dim c As Long, Rapport8 As Long
Dim myRange As Range
Dim myCell As Range

Set myRange = Range("AD2", Range("AD" & Rows.Count).End(xlUp))

For Each myCell In myRange '
    c = c + 1
    If (myCell) <> "SPLICE" Then
        myCell.Offset(0, 1).Interior.Color = RGB(255, 87, 87)
    Else
        myCell.Offset(0, 1).Interior.Pattern = xlNone
    i = i + 1
    End If
Next myCell

Rapport8 = i

 
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM