

Only the last 8 digits on the right are relevant. Line 95: 16737843 And 255 returns 51, 51 \ 1 returns 51, remainder 0įurther details of the binary And are provided in figure 5.' omitted (&HFF00), the assigned value is -256 ' leading &H is the prefix radix (base) for hexadecimal R = (ColDec And &HFF) \ 256 ^ 0 ' &HFF hexadecimal = 255 decimal Includes test routineįunction xlfDec2RGB(ByVal ColDec As Long) As String The ColorConstants Auto List drop down is shown in figure 4.įig 4: VBA ColorConstants - VBA Auto List drop down with 8 itemsĬode 3 prints a list of the ColorConstants numerical values to the immediate window (figure 5).Ĭode 5: Function xlfDec2RGB converts color decimal to RGB comma separated values. The 8 colours listed in section 1.1 have name equivalents listed as members of the VBA ColorConstants class in the decimal colour system. Ten of the ColorIndex colours are duplicate pairs: Offset(i - 1, j - 1).Font.ColorIndex = 1 Offset(i - 1, j - 1).Font.ColorIndex = 2 Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.Code 2: Sub ColIndx2WSarraS procedure prints ColorIndex to WS array (7 rows by 8 columns)Ĭonst TLC As String = "B2" ' top left cell Functions (Visual Basic for Applications).MyObject.Color = RGB(255, 0, 0) ' Set the Color property of MyObject to Red. Red = RGB(255, 0, 0) ' Return the value for Red. If MyObject does not exist, or if it does not have a Color property, an error occurs. The object MyObject and its property are used for illustration purposes only. It is used for those application methods and properties that accept a color specification. This example shows how the RGB function is used to return a whole number representing an RGB color value. They may be used within the context of Microsoft applications for the Macintosh, but should not be used when communicating color changes directly to the Macintosh operating system. The RGB color values returned by this function are incompatible with those used by the Macintosh operating system. The following table lists some standard colors and the red, green, and blue values they include: Color The value for any argument to RGB that exceeds 255 is assumed to be 255. An RGB color value specifies the relative intensity of red, green, and blue to cause a specific color to be displayed. Number in the range 0–255, inclusive, that represents the blue component of the color.Īpplication methods and properties that accept a color specification expect that specification to be a number representing an RGB color value. Number in the range 0–255, inclusive, that represents the green component of the color. Number in the range 0–255, inclusive, that represents the red component of the color. The RGB function syntax has these named arguments: Part Returns a Long whole number representing an RGB color value.
