簡體   English   中英

如何根據另一個單元格值突出顯示單元格值

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

我正在研究一個突出顯示&colors特定列(AE)中的空單元格的宏,但我需要根據列(AD)中存在的結果清除此顏色突出顯示

如果 AD 列,單元格 value = "SPLICE" 清除顏色,如果為 Empty,顏色應該存在,下圖解釋更多。 我使用下面的代碼

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

在此處輸入圖像描述

嘗試按照以下代碼使用偏移量:

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