How to darken or lighten an RGB color in VB/A

Generate a light or dark color shade from an RGB color value.

The ShadeColor() function takes an RGB color value (a Long) and applies a shading algorithm, converting to HSV to darken or lighten the color, then back to RGB to use it in VB/A.

Download sample Access database with the code.
Then open the frmShadeTest form to see it in action.

Function signature:

This is just my refactoring of the code I found in the following article:
https://www.thespreadsheetguru.com/blog/vba-macro-code-lighten-darken-fill-colors-excel

I found it clever and handy, although had a tough time figuring out the type of the variables used in the body to refactor it to my preference.

Read the original article for a full explanation of the process.

I’m on twitter @francescofoti