Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 按条件格式着色的单元格的VBA_Excel_Vba_Excel Formula_Conditional Formatting_Getcolor - Fatal编程技术网

Excel 按条件格式着色的单元格的VBA

Excel 按条件格式着色的单元格的VBA,excel,vba,excel-formula,conditional-formatting,getcolor,Excel,Vba,Excel Formula,Conditional Formatting,Getcolor,我希望我能在这里得到答案。 这一定是个简单的问题,但我现在别无选择 我有一张表格,其中我使用条件格式来突出显示单元格,在另一张表格中,我想获得该单元格的颜色,因此我在下面创建了VBA函数,以便使用公式获得颜色 这是我的VBA函数 Function GetColouring(FCell As Range) GetColouring = FCell.Interior.ColorIndex End Function 这是我工作表中的公式,用来计算细胞的颜色。 =@getcoloring(

我希望我能在这里得到答案。 这一定是个简单的问题,但我现在别无选择

我有一张表格,其中我使用条件格式来突出显示单元格,在另一张表格中,我想获得该单元格的颜色,因此我在下面创建了VBA函数,以便使用公式获得颜色

这是我的VBA函数

Function GetColouring(FCell As Range)

    GetColouring = FCell.Interior.ColorIndex

End Function
这是我工作表中的公式,用来计算细胞的颜色。
=@getcoloring(偏移量(POAP!$I$5、$A20、$B20+($C20-1)*19))

我将其与偏移公式一起使用,这是因为我的工作表采用了条件格式。 如果单元格是手动着色的,但只有在条件格式设置时才返回“白色或-4142”,则它才起作用。我已经尝试了谷歌的其他建议代码
getcoloring=FCell.displayformt.Interior.Color
但它只会返回#值


什么是正确的代码,以便我可以通过条件格式突出显示单元格的颜色。

DisplayFormat
是您需要的属性,但您不能在从工作表调用的UDF中使用它。您好,如果我不能使用UDF,我应该使用什么函数?是否确实要将颜色索引写入另一个单元格?你想用它解决什么问题?它没有函数。您可以为它创建一个自定义项,但根据所涉及的格式标准,它将非常复杂。我怀疑有更好的方法来实现你的最终目标,不管是什么。不是答案:你不愿意把条件格式的公式放在你的UDF中,并显示一些真实的结果,比如“好”、“差”、“好”吗?捕捉颜色已经指日可待了。另外,单元格没有颜色,它只有分别起作用的条件格式。