简体   繁体   English

如何编写这一行代码以考虑VBA的绝对值?

[英]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!)... 这是它可以做的最简单的示例(比我们可以给您的代码示例好得多!)...

条件格式1

条件格式2

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 . 一个常被问到的问题是如何根据一个单元格的值突出显示整个过程

.

Something awesome made from Conditional Formatting: 由条件格式制作的很棒的东西:

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转换器提升到了一个全新的水平!

.

PIXEL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何编写VBA代码,使公式返回所选单元格中的值? - How do I write VBA code such that my formula returns the value in the selected cell? 如何在vlookup VBA中将lookup_value写入范围 - How do I write the lookup_value in vlookup VBA as a range VBA:QueryTables:如何不考虑TextFileOtherDelimiter - VBA : QueryTables : how to NOT take into account TextFileOtherDelimiter 如何检查VBA中的给定路径是相对路径还是绝对路径? - How do I check if a given path is relative or absolute in VBA? 我如何在VBA中为此代码编写循环 - How can I write a loop in vba for this code 如何在 A1 中使用我的单元格值并将此值写入另一个 vba 代码? - How can I use my cell value in A1 and write this value into another vba code? 如何编写VBA代码,当我按下Enter键时,该代码将允许我从一个单元格跳到另一个单元格 - How do I write VBA code that will allow me to jump from cell to cell as I hit the enter key VBA:如何使用真/假方法和 VLookup 代码编写 If 语句? - VBA: How do I write an If statement using a true/false method and VLookup code? 如何编写VBA代码以重命名根文件夹下的所有文件夹? - How do I write a VBA code to rename all folders under a root folder? 我将如何编写 VBA 代码以将文件名保存为单元格值的 Excel 工作簿? - How would I write VBA code to save an excel workbook with the filename as a cell value?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM