简体   繁体   English

根据三个单元格中的RGB值自己制作单元格颜色

[英]Make a cell color itself based on RGB value in three cells

I have no idea why this code doesn't work. 我不知道为什么这段代码行不通。

Function colorme(Red As Integer, Green As Integer, Blue As Integer)
    Application.Caller.Interior.color = RGB(Red, Green, Blue)
End Function

I want to make it work in spreadsheet like: 我想使其在电子表格中起作用,例如:

__red__|_green_|_blue__|_color_|_
____50_|_____0_|____60_|#purple|_

But the #purple is actually purple, using colorme(A2,B2,C2). 但是#purple实际上是使用colorme(A2,B2,C2)紫色的。

A user-defined function cannot change any properties of a cell except the value of the cell that contains the formula. 用户定义的函数不能更改单元格的任何属性,但包含公式的单元格的值除外。 You could write a subroutine to change the colors of the cells, but unless I'm mistaken, the way you're trying isn't possible. 您可以编写一个子例程来更改单元格的颜色,但是除非我弄错了,否则您尝试的方法是不可能的。

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

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