简体   繁体   中英

How to change the background of a cell in excel, by using a formula, no Conditional Formatting

I have a column with numbers 0 to 100 and I want to change the background colour of the next column according to those values with 0 as red, and 100 as normal green and as the number gets higher, the colour fades from red to light red, to white in 50 and then, light green to green in 100

The question is how do I do that, without using conditional formatting

I was trying to use ColourIndex, as

=Range("A1").Interior.ColorIndex = RGB(255,0,0)

but the function is not working, and I do not want to use conditional formatting

Any ideas?

If you don't want to use conditional formatting, your only other avenue is VBA. But this can easily be done with ONE SINGLE conditional format applied to the range of 100 cells.

If you want to format the column to the right of the original values, use a formula to pull the values from the column to the left, then apply a color scale conditional format to the target column.

Set a custom number format of ;;; to hide the numbers in the formatted column.

在此处输入图片说明

Answering your question as stated in your title (How to change the background of a cell in excel, by using a formula, no Conditional Formatting) - You can't. Not with a worksheet formula.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM