RGB function

Category: Color / Misc

Summary

RGB color value.

Syntax

RGB(red, green, blue) The RGB function syntax has these named arguments:
Part
Description
redRequired; Variant (Integer). Number in the range 0–255, inclusive, that represents the red component of the color.
greenRequired; Variant (Integer). Number in the range 0–255, inclusive, that represents the green component of the color.
blueRequired; Variant (Integer). Number in the range 0–255, inclusive, that represents the blue component of the color.

Example

Example
This example shows how the RGB function is used to return a whole number representing an RGB color value. It's used for those application methods and properties that accept a color specification. The object MyObject and its property are used for illustration purposes only. If MyObject does not exist, or if it does not have a Color property, an error occurs.
Dim Red, I, RGBValue, MyObject
Red = RGB(255, 0, 0) ' Return the value for Red.
I = 75 ' Initialize offset.
RGBValue = RGB(I, 64 + I, 128 + I) ' Same as RGB(75, 139, 203).
MyObject.Color = RGB(255, 0, 0) ' Set the Color property of MyObject to Red.

Microsoft Support Page

https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/rgb-function

Back to Functions