Excel - 如果突出显示同一行中的另一个单元格,则填充值为1的单元格

时间:2012-12-19 03:39:06

标签: excel excel-vba vba

如果Col. B中的值突出显示为黄色,我需要更改Col. A中单元格中的值。

我已经看到相反的解决方案(根据Col.A中的值突出显示行/单元格,如:Change background color of more than one cell on the same row when another cell has a certain numeric value in Excel 2010),但我需要标记/标记行(带有数字,如“1” “)突出显示,以便我可以将其导出为.csv或.txt格式的统计程序。

1 个答案:

答案 0 :(得分:1)

确定单元格填充颜色的唯一方法是使用VBA

这是一个执行此操作的UDF

Function GetCellColour(r As Range) As Long
    GetCellColour = r.Cells(1, 1).Interior.Color
End Function

或者如果您愿意

Function GetCellColourIndex(r As Range) As Long
    GetCellColourIndex = r.Cells(1, 1).Interior.ColorIndex
End Function

然后在像

这样的单元格公式中使用它
=IF(GetCellColour(A1)=65535,"Cell is yellow","")

=IF(GetCellColourindex(A2)=6,"Cell is yellow","")
相关问题