简体   繁体   English

从另一个单元格值中突出显示单元格(动态范围)

[英]Highlight cell from another cells value (dyanmic range)

After digging through very similar posts I just can't find a solution to my unique request.在挖掘了非常相似的帖子后,我无法找到满足我独特要求的解决方案。 I have been able to build a formula up to this point using those threads but I am just getting confused with having two IF statements.到目前为止,我已经能够使用这些线程构建一个公式,但我只是对有两个 IF 语句感到困惑。

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If ActiveCell.Address = "$U$14" Then
    Dim rng As Range, cell As Range, LastRow As Long

    With Sheets("Sheet4")
        LastRow = .Range("B" & .Rows.Count).End(xlUp).Row
    End With

    Set rng = Range("A2:A" & LastRow)

    'If O2:O200 is BLANK then highlight corresponding row (xlUp) in Column A yellow
    For Each cell In rng
        cell.Interior.ColorIndex = 27
    Next
Else
    cell.Interior.ColorIndex = 2
End If

End Sub

What I want to do is for every cell starting with O2 through O & LastRow IF it is blank then highlight corresponding row (xlUp) in column A.我想要做的是对于从 O2 到 O & LastRow 的每个单元格,如果它是空白的,然后突出显示 A 列中的相应行(xlUp)

(xlUp) - Because I want it to highlight the person's name and not just the row, meaning that person has not yet collected an Item. (xlUp) - 因为我希望它突出显示这个人的名字,而不仅仅是行,这意味着那个人还没有收集到一个项目。

Then when clicked off of cell U14 set it back to normal.然后当点击单元格 U14 时将其设置回正常。

Sorry it is so sloppy, I tried to put as much in it as I could figure out on my own.对不起,它太草率了,我试着把我自己能想到的尽可能多的放进去。

EXAMPLE:例子: 例子

Thanks to Scott Craner for solving my highlighting issue using some clever conditional formatting, In order to solve the ability of toggling the conditional formatting via activating a cell I did the following in case anyone wants to know:感谢 Scott Craner 使用一些巧妙的条件格式解决了我的突出显示问题,为了解决通过激活单元格来切换条件格式的能力,我做了以下事情以防万一有人想知道:

I set a conditional format ABOVE the feature that removed all formatting and checked "Stop If True".我在删除所有格式并选中“如果为真则停止”的功能上方设置了条件格式。 The formula used was:使用的公式是:

    =NOT($U$12)
'U12 is the dedicated cell for displaying TRUE or FALSE, use any cell

I then utilized the following VBA to essentially toggle a cell to be true or false which then triggered the no format conditional to be true if a specific cell was selected and false when not:然后,我使用以下 VBA 基本上将单元格切换为真或假,然后触发无格式条件为真,如果选择特定单元格,则为假:

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If ActiveCell.Address = "$U$14" Or ActiveCell.Address = "$U$13" Then
    Range("$U$12").Value = True
Else
    Range("$U$12").Value = False
End If

End Sub

Now whenever I highlight the cells U13 or U14 all names within Column A that have not Collected will be highlighted.现在,每当我突出显示单元格 U13 或 U14 时,A 列中尚未收集的所有名称都将突出显示。

暂无
暂无

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

相关问题 突出显示另一个单元格中包含值的所有单元格 - Highlight all cells that contain a value in another cell 根据另一个单元格值更改单元格范围 - Change range of cells base on another cell value 根据另一个单元格的值更新一系列单元格 - Updating a range of cells based on the value of another cell 需要一系列单元格的公式 - 根据另一个单元格区域中存在的值来突出显示单元格 - Need formula for a range of cells - to highlight cells based on the presence of a value in another range of cells 当单元格的总和达到 Excel 中另一个单元格的值时突出显示单元格 - Highlight cells when its sum reached the value on another cell in Excel 如何根据另一个像元值​​VBA突出显示一个像元? - How to highlight a cell based on another cells value VBA? (Excel) 有没有办法根据另一个单元格的值从一系列单元格中对单元格进行条件格式设置? - (Excel) Is there a way to conditional format a cell from a range of cells based on the value of an another cell? 将值从工作表中的单元格复制到一系列单元格中 - Copy the value from a cell in a worksheet into a range of cells EXCEL:需要在另一个工作表的单元格范围内查找值,并从相邻单元格返回值 - EXCEL: Need to find a value in a range of cells from another worksheet and return value from adjacent cell Excel - 如果单元格范围等于列表中的值,我想填充另一个单元格的值 - Excel - if a range of cells equals a value from a list I want to populate the value of another cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM