View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Get a color name from any RGB combination?

I stumbled across this nice one:
http://gauth.fr/2011/09/get-a-color-...b-combination/

Very neat indeed :-)


Yes.., quite impressive to say the least!
But made in JavaScript, which I know virtual nothing about...

I was wondering, if anyone has made something similar in VBA?


Don't know, but maybe Karl Peterson has something you can modify to do
similar.

Can it be done?
How?


Simplest approach:
Parse the file "dataset.js" into columns and use a lookup function to
return a name based on user input. (I'd probably have it work both
ways, meaning user can optionally enter a name and return the RGB
value!)

I see that this file is one continuous string and so may need to be
edited so you can use Split() for each color name value. As is.., you
can parse each piece of color data using "}," as a delimiter to load
your initial array.

After that each element is a comma delimited set of property:value
pairs where you can Split() each part into a temp array, then split
again into a 2nd temp array using ":" as the delimiter. (you only need
to extract the UBound value of this 2nd array)

Once you get there you can decide how to put the table into a
worksheet. I'd probably build an output 2D array in memory, then 'dump'
that into the worksheet (OR a delimited file where I can search for my
RGB values, OR just store the data so it's easily retrievable into a
workable array at runtime)!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion