VBA Excel - The color codes

Ask a question

VBA Excel - The color codes


Color codes

The image below list the color codes:


The sample workbook can be downloaded from this link: http://cjoint.com/?DIqlTjoC61G

The conversion function:

This function allows you to convert VBA colour codes from 1 to 56 (Interior.ColorIndex) to their long value (Interior.Color):
Function CouversionCouleurLong(Couleur As Integer) As Long
Dim CouleursLng()
CouleursLng = Array(0, 16777215, 255, 65280, 16711680, 65535, 16711935, 16776960, 128, 32768, 8388608, 32896, 8388736, 8421376, _
12632256, 8421504, 16751001, 6697881, 13434879, 16777164, 6684774, 8421631, 13395456, 16764108, 8388608, 16711935, 65535, _
16776960, 8388736, 128, 8421376, 16711680, 16763904, 16777164, 13434828, 10092543, 16764057, 13408767, 16751052, 10079487, _
16737843, 13421619, 52377, 52479, 39423, 26367, 10053222, 9868950, 6697728, 6723891, 13056, 13107, 13209, 6697881, 10040115, 3355443, 16777215)
'En cas d'erreur colorie en noir
If Couleur < 0 Or Couleur > 56 Then CouversionCouleurLong = 0
CouversionCouleurLong = CouleursLng(Couleur)
End Function

Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Related