【发布时间】:2014-04-17 10:49:07
【问题描述】:
我编写了下面的函数来测试单元格是否根据单元格填充激活了条件格式。
Function cfTest(inputCell)
If inputCell.DisplayFormat.Interior.Color <> 16777215 Then
cfTest = True
Else
cfTest = False
End If
End Function
但它不起作用。话说,这个方法可以。
Sub myCFtest()
Dim R As Integer
R = 2
Do
If Range("I" & R).DisplayFormat.Interior.Color <> 16777215 Then
Range("K" & R).Value = True
Else
Range("K" & R).Value = False
End If
R = R + 1
Loop Until R = 20
End Sub
谁能向我解释为什么该功能不起作用?
干杯。
编辑:更新了函数,但不适用于条件格式
Function cfTest(inputCell)
If inputCell.Interior.ColorIndex <> -4142 Then
cfTest = True
Else
cfTest = False
End If
End Function
【问题讨论】:
-
您是否像这样从单元格调用此函数:
=cfTest(A1)?如果是,DisplayFormat在从工作表中调用 UDF 函数时不起作用。详情请参阅此链接中的备注:msdn.microsoft.com/en-us/library/office/… -
这正是我想要做的——从工作表中调用它。感谢您的链接。不幸的是,当我删除 DisplayFormat 它可以工作,但不适用于有条件格式化的单元格。有小费吗?将编辑帖子更新但仍无法正常工作的功能....
标签: excel function vba conditional-formatting