Link to home
Start Free TrialLog in
Avatar of Flora Edwards
Flora EdwardsFlag for Sweden

asked on

how can i return the name of color from the cell background?

how can i return the name of color from the cell background? for example if cell color is green, i put a function like cell colorname(a1) and it should return green.
ASKER CERTIFIED SOLUTION
Avatar of Professor J
Professor J

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
for me there are so many shading in colors that ir would be practically impossible to code all the color combinations. For sure it is possible to put an array for the basic colors, but then again what guarantee that the color chosen in the cell falls in the array preset ??

May I ask why you need this as the question is quite opened. Maybe we can help you if you give more info as to the use of it.
gowflow
Well just saw professor's reply in 11 seconds earlier than me, and that is what I meant by coding an array for the basic colors !!! try putting variance and this wont work.

try shading of blue or anything ...
gowflow
Here is short version:
Function GetColor(r As Range) As Integer
GetColor = r.Interior.ColorIndex
End Function

Open in new window

Suppose your color is in A1, use below formula in B1:
=GetColor(A1)

Open in new window

Avatar of Flora Edwards

ASKER

thanks both.

the code worked.  i had only 7 colors and it worked for me.
thanks so very much gowflow.  you are right, if i had many colors, then it would not have worked.  right now my workbook has 7 colors which the UDF worked, but it has another problem of returning error which i opened another question.

thanks Shams.
please post the link to the question and I will be glad to help.
gowflow