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.


(function() { var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true; po.src = ‘https://apis.google.com/js/plusone.js’; var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s); })();

Author: bm082975

Leave a Reply

Your email address will not be published. Required fields are marked *