[英]How do I write this line of code to take into account the absolute value VBA?
Here is my code 这是我的代码
If Range("E" & i).Value > Range("C" & i).Value * 0.2 Then Range("E" & i).Interior.Color = 13619199
This line of code is meant to highlight all cells in column E if column E is 20% greater than column C. The code works. 如果E列比C列大20%,则此行代码应突出显示E列中的所有单元格。此代码有效。 However, I want it to highlight the absolute value of E as well because I have some negative values in there as well.
但是,我也希望它突出显示E的绝对值,因为其中也有一些负值。 How do I get this line of code to take into account the negative values?
如何获得这一行代码以考虑负值?
I appreciate all answers in advance. 我非常感谢所有答案。
Thanks, 谢谢,
G G
This wasn't asked in your original question but your comments give the impression that you're unfamiliar with Conditional Formatting? 您的原始问题中没有问这个问题,但是您的评论给人的印象是您不熟悉条件格式? This is the simplest example of what it can do (better than and quick code samples we can give you!)...
这是它可以做的最简单的示例(比我们可以给您的代码示例好得多!)...
There are many other ways conditional formatting can be used, some trickier than others to setup, but all with plenty of examples available online. 条件格式化还有很多其他的使用方式 ,其中一些设置比其他设置更为棘手,但所有方法都在线提供了许多示例。 A commonly asked one is how to highlight an entire how based on the value of one cell .
一个常被问到的问题是如何根据一个单元格的值突出显示整个过程 。
. 。
Lastly, on the topic of Conditional Formatting being cooler than it sounds, a mathematician took it to a whole new level with a Conditional Formatting-based JPG-to-Excel convertor that's worth checking out! 最后,关于条件格式比听起来酷的话题,一位数学家将其与基于条件格式的JPG转换为Excel的Excel转换器提升到了一个全新的水平!
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.