VBA procedures for CIE LabLch and HSL color scheming

In playing around with color in VBA I introduced a bunch of functions to manipulate various color spaces from VBA. Digging into the whole topic a little more, I wondered if it would be possible to create color palettes from a single color. After some research, I figured that I would try the cie LabLch and HSL color spaces to see how I might do this.

The maths behind all this turned out to be pretty interesting, and I had to dust off some rusty trig concepts to get this working, but I now have a very extensive set of VBA functions to manipulate color.

First attempts

I decided to generate a set of 5 colors evenly spaced according to hue, lightness and saturation using each model to compare how close they were. Later on I’ll make some functions for other schemes, and of course create a google apps script version.
I generated some random colors and made the palettes as described above. Here are the generated results.
I prefer the results using the hsl space. What do you think?
Here’s the code to create these random palettes. You can download the cDataSet.xlsm workbook from the Excel Liberation site to play around with it. It’s the worksheet named ‘palette’

The color manipulation functions.

Here is the code, or you can find it in the downloads section, the cDataSet.xlsm workbook on  the Excel liberation site. Here are the functions you’ll find there.


About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.

Be the first to comment

Leave a Reply

Your email address will not be published.


six + 3 =