Excel条件格式可以在条件中使用UDF吗?

时间:2022-08-14 20:26:09

I have a cell in Excel that I want to format differently based on a user defined formula (UDF) - my formula tests whether there is a formula in the cell...

我在Excel中有一个单元格,我希望根据用户定义的公式(UDF)进行不同的格式化 - 我的公式测试单元格中是否有公式...

I am trying to use conditional formatting with my UDF to format the cell - but it does not seem to be working.

我试图使用我的UDF条件格式来格式化单元格 - 但它似乎没有工作。

My condition is this:

我的情况是这样的:

="isManualPrice(R22C12)"

I tried without the quotes, but get the error

我尝试没有引号,但得到错误

You cannot use references to other worksheets or workbooks for Conditional Formatting criteria

您不能对条件格式标准使用对其他工作表或工作簿的引用

Perhaps the issue relates to my UDF being defined in a separate macro workbook and not my main workbook...

也许这个问题与我在单独的宏工作簿中定义的UDF有关,而不是我的主要工作簿......

I see its mentioned in this blog entry from 2005, but only in passing...

我在2005年的博客文章中看到了它,但只是顺便提一下......

Thanks in advance. Chris

提前致谢。克里斯

1 个解决方案

#1


2  

Yes, it can.

是的,它可以。

Your problem is simply that you've got quotes in there. You need to choose "Formula Is" from the drop-down, and then your formula should be

你的问题只是你在那里有引号。您需要从下拉列表中选择“公式是”,然后您的公式应该是

=isManualPrice(R22C12)

...with no quotes.

......没有引号。

(I'm more used to A1 notation rather than R1C1 notation but I assume that'll work just as well).

(我更习惯于A1符号而不是R1C1符号,但我认为它也能正常工作)。

#1


2  

Yes, it can.

是的,它可以。

Your problem is simply that you've got quotes in there. You need to choose "Formula Is" from the drop-down, and then your formula should be

你的问题只是你在那里有引号。您需要从下拉列表中选择“公式是”,然后您的公式应该是

=isManualPrice(R22C12)

...with no quotes.

......没有引号。

(I'm more used to A1 notation rather than R1C1 notation but I assume that'll work just as well).

(我更习惯于A1符号而不是R1C1符号,但我认为它也能正常工作)。