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:
1 |
Public Function ShadeColor(ByVal plColor As Long, ByVal piShadeRate As Integer) As Long<br> |
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
Recent Comments