1 Attachment(s)
Function to write the Interior Color
Hi All,
One looks like a simple question but i cannot solve it.
Basically, i have written a self-defined function which is write the name of color to fulfill the interior color into cell.
[vba]Public Function CoIndex(str As String) As Variant
Select Case LCase(str)
Case "red": CoIndex = 3
Case "yellow": CoIndex = 6
End Select
ThisCell.Interior.ColorIndex = CoIndex
End Function[/vba]
In the above function, i have defined the actual color index.
For example, if i type the formula in Cell A1=CoIndex("red"), then i want the cell shading in Cell A1 will be a red color.
Now the result has a error if it has this sentences "ThisCell.Interior.ColorIndex = CoIndex"
If i crossout this sentences, it will return the number of colorindex.
It is Interesting in this findings.
Thanks,
Ann