Code of colors in excel

Содержание

  1. Excel Format Colors
  2. Colors
  3. Theme and Standard Colors
  4. Hexadecimal Colors
  5. RGB Colors
  6. Applying colors
  7. Excel VBA color code list – ColorIndex, RGB color, VB color
  8. Excel ColorIndex
  9. Excel RGB color
  10. Excel VB color
  11. Excel VBA: ColorIndex Codes List & RGB Colors
  12. VBA Color Index Codes List
  13. VBA ColorIndex Examples
  14. Set Cell Background Color
  15. Set Cell Font Color
  16. Set Cell Borders Color
  17. Get Cell Background ColorIndex
  18. Set a Cell Background Color to Another Cell’s Color
  19. VBA Color Property
  20. VB Color
  21. Set Cell Background Color
  22. Set Cell Font Color
  23. Set Cell Borders Color
  24. Set a Cell Background Color to Another Cell’s Color
  25. RGB Colors
  26. ColorIndex Codes List & RGB Colors in Access VBA
  27. VBA Code Examples Add-in
  28. VBA Excel. Стандартная палитра из 56 цветов
  29. Стандартная палитра из 56 цветов
  30. Наименования 56 цветов палитры
  31. RGB и HEX коды оттенков палитры
  32. Процент черного в оттенках серого
  33. Вывод 56-цветной палитры на лист

Excel Format Colors

Colors

Colors are specified by selection or by using Hexadecimal and RGB codes.

Tip: You can learn more about colors in our HTML/CSS Colors Tutorial.

Theme and Standard Colors

Excel has a set of themes and standard colors available for use. You select a color by clicking it:

The «More Colors» option allows you to select custom colors by entering a RGB or HEX code.

Hexadecimal Colors

Excel supports Hexadecimal color values

A hexadecimal color is specified with: # RR GG BB .

RR (red), GG (green) and BB (blue) are hexadecimal integers between 00 and FF specifying the intensity of the color.

For example, #0000FF is displayed as blue, because the blue component is set to its highest value (FF) and the others are set to 00.

RGB Colors

Excel supports RGB color values.

An RGB color value is specified with: rgb( RED , GREEN , BLUE ) .

Each parameter defines the intensity of the color as an integer between 0 and 255.

For example, rgb(0,0,255) is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0.

Tip: Try W3schools.com color picker to find your color! https://www.w3schools.com/colors/colors_picker.asp

Applying colors

Colors can be applied to cells, text and borders.

Colors are applied to cells by using the «Fill color» function.

How to apply colors to cells:

  1. Select color
  2. Select range
  3. Click the Fill Color button

The «Fill color» button remembers the color you used the last time.

Color options are explored by clicking on the arrow-down icon (), next to the Fill color command:

The option allows selection of theme colors, standard colors or use of HEX or RGB codes by clicking on the More Colors option:

Colors are made from red, green, blue and are universal. Entering a color in one way will give you the code in the other. For example if you enter a HEX code, it will give you the RGB code for the same color.

Let’s try some examples.

Starting with theme and standard colors:

Great!

Try to apply the following colors:

  • Theme color blue (accent 5) to A3:F3.
  • Theme color green (accent 6) and A5:F5.

Did you make it?

Let’s apply colors using HEX and RGB codes.

Apply HEX code #ffcb05 to A7:F7:

  1. Select A7:F7
  2. Open color options
  3. Click More colors
  4. Insert #ffcb05 in the HEX input field
  5. Hit enter

Notice that applying the HEX code gives the RGB code for the same color, and shows where that color is positioned on the color map.

Apply RGB code 60 , 90 , 166 to A9:F9

  • Select A9:F9
  • Open color options
  • Click More colors
  • Insert 60 , 90 , 166 in the RGB input field
  • Hit enter

Notice that entering the RGB code also gives the HEX code and shows you where the color is positioned on the color map.

Well done! You have successfully applied colors using the standard, theme, HEX and RGB codes.

Источник

Excel VBA color code list – ColorIndex, RGB color, VB color

This Excel tutorial collects the VBA color code list for reference purpose, which includes ColorIndex, RGB color, VB color.

Excel ColorIndex

VBA Excel ColorIndex Property is to set color or get color for Objects like Cell color and Shape color. ColorIndex offers 56 basic colors plus the following special numbers.

ColorIndex Value Explanation
-4142 / xlColorIndexNone / xlNone No fill
-4105 / xlColorIndexAutomatic / xlAutomatic Default color (white)

Example 1: Set Cell A1 font color to red

Example 2: Set Cell A1 back color to red

Example 3: Set Cell A1 border color to red

Example 4: Get Cell A1 ColorIndex

Excel RGB color

VBA Excel RGB Property is a color Property of Objects, commonly used for Cell color or Shape color.

“RGB” stands for Red Green Blue, which are known as three primary colors, which can be combined to produce other colors. For example, purple is a mix of blue and red. In RGB Property, you need to give a value (from 0 to 255) for each color in order to mix a new color. For example, Red = 255 means the brightness of color red is 100%.

If you try to change a color but you don’t know the color code, you can visit the websites below

Example 1: Set Cell A1 font color to red

Example 2: Set Cell A1 back color to red

Example 3: Set Cell A1 border color to red

Excel VB color

The simplest way to apply color is using the VB color name, you don’t have to remember which number represents which color, the the color for your choice is very limited.

Источник

Excel VBA: ColorIndex Codes List & RGB Colors

In this Article

VBA Color Index Codes List

When using VBA to code the Colorindex (or background color) of a cell it is useful to know what integer will equal what color. Below is a reference picture which shows the color and lists it’s respective Colorindex. aka VBA Color Palette

Here’s the code to make one for yourself, or just bookmark this page:

VBA ColorIndex Examples

Set Cell Background Color

This example sets the cell’s background color.

Set Cell Font Color

This example sets the cell’s font color.

Set Cell Borders Color

This example sets the cell’s border color.

Get Cell Background ColorIndex

This example gets the cell’s background color and assigns it to an Integer variable.

Set a Cell Background Color to Another Cell’s Color

This example sets a cell color equal to another cell color.

VBA Color Property

Instead of using Excel / VBA’s ColorIndex property, you can use the Color property. The Color property takes two input types:

We will discuss these below:

VB Color

VB Color is the easiest way to set colors in VBA. However, it’s also the least flexible. To set a color code using vbColor use the table below:

However, as you can see from the table, your options are extremely limited.

Set Cell Background Color

Set Cell Font Color

Set Cell Borders Color

Set a Cell Background Color to Another Cell’s Color

RGB Colors

RGB stands for Red Green Blue. These are the three primary colors that can be combined to produce any other color. When entering colors as RGB, enter a value between 0 and 255 for each color code.

Here’s an example:

Above we’ve set Red = 255 (max value), Green = 255 (max value), and Blue = 0 (min value). This sets the cell background color to Yellow.

Instead we can set the cell font color to purple:

There are numerous online tools to find the RGB code for your desired color (here’s one).

ColorIndex Codes List & RGB Colors in Access VBA

Access uses forms to display data. You can use the ColorIndex Codes to programmatically change the background color and foreground color of objects in your Access forms.

VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

Источник

VBA Excel. Стандартная палитра из 56 цветов

Наименования цветов стандартной палитры Excel из 56 оттенков на русском и английском языках. Соответствие цветов индексам VBA и их RGB и HEX коды.

Стандартная палитра из 56 цветов

За ограниченную палитру в VBA Excel отвечает свойство ColorIndex, которое используется для записи и чтения:

Свойство ColorIndex принимает и возвращает значения от 1 до 56.

Наименования 56 цветов палитры

Наименования 56 цветов стандартной ограниченной палитры Excel на русском и английском языках:

Индекс Наименование
по-русски
Наименование по-английски Оттенок
1 Черный Black
2 Белый White
3 Красный Red
4 Лайм Lime
5 Синий Blue
6 Желтый Yellow
7 Фуксия* Fuchsia*
8 Цвет морской волны Aqua
9 Темно-бордовый Maroon
10 Зеленый Green
11 Темно-синий Navy blue
12 Оливковый Olive
13 Пурпурный Purple
14 Бирюзовый Teal
15 Серебряный Silver
16 Серый Gray
17 Светло-пурпурно-синий Light purple blue
18 Розовато-лиловый Mauve
19 Бледно-желто-зеленый Pale yellow green
20 Бледно-голубой Pale blue
21 Сливовый Plum
22 Лососевый Salmon
23 Темно-сине-голубой Light navy blue
24 Барвинок Periwinkle
25 Темно-синий Navy blue
26 Фуксия* Fuchsia*
27 Желтый Yellow
28 Цвет морской волны Aqua
29 Пурпурный Purple
30 Коричнево-малиновый Maroon
31 Сине-зеленый Teal
32 Синий Blue
33 Небесно-голубой Vivid sky blue
34 Бледно-голубой Pale blue
35 Бледно-зеленый Pale green
36 Светло-желтый Light yellow
37 Сине-голубой Shade of blue
38 Бледно-пурпурно-розовый Pale magenta pink
39 Светло-сиреневый Light lilac
40 Оранжево-персиковый Peach-orange
41 Светло-синий Light blue
42 Светло-бирюзовый Light turquoise
43 Желто-зеленый Yellow green
44 Желтый мандарин Tangerine yellow
45 Сигнальный оранжевый Safety orange
46 Оранжевый Orange
47 Темно-сине-серый Dark blue gray
48 Светло-серый Light gray
49 Полуночно-синий Midnight blue
50 Зеленая трава Green grass
51 Темно-зеленый Dark green
52 Темно-коричневый Dark brown
53 Темно-красный Dark red
54 Розовато-лиловый Mauve
55 Синий пигмент Blue pigment
56 Темный уголь Dark charcoal

* Вместо термина Фуксия (Fuchsia) можно использовать термин Маджента (Magenta), так как в RGB-модели Фуксия и Маджента являются одним и тем же цветом.

Обратите внимание, что в стандартной палитре Excel из 56 цветов есть повторяющиеся оттенки. Наименования цветов (по их HEX-кодам) подобраны, главным образом, по статьям, опубликованным в Википедии.

RGB и HEX коды оттенков палитры

RGB и HEX коды оттенков 56-цветной палитры Excel:

Индекс Код HEX Код RGB Оттенок
1 #000000 RGB(0, 0, 0)
2 #ffffff RGB(255, 255, 255)
3 #ff0000 RGB(255, 0, 0)
4 #00ff00 RGB(0, 255, 0)
5 #0000ff RGB(0, 0, 255)
6 #ffff00 RGB(255, 255, 0)
7 #ff00ff RGB(255, 0, 255)
8 #00ffff RGB(0, 255, 255)
9 #800000 RGB(128, 0, 0)
10 #008000 RGB(0, 128, 0)
11 #000080 RGB(0, 0, 128)
12 #808000 RGB(128, 128, 0)
13 #800080 RGB(128, 0, 128)
14 #008080 RGB(0, 128, 128)
15 #c0c0c0 RGB(192, 192, 192)
16 #808080 RGB(128, 128, 128)
17 #9999ff RGB(153, 153, 255)
18 #993366 RGB(153, 51, 102)
19 #ffffcc RGB(255, 255, 204)
20 #ccffff RGB(204, 255, 255)
21 #660066 RGB(102, 0, 102)
22 #ff8080 RGB(255, 128, 128)
23 #0066cc RGB(0, 102, 204)
24 #ccccff RGB(204, 204, 255)
25 #000080 RGB(0, 0, 128)
26 #ff00ff RGB(255, 0, 255)
27 #ffff00 RGB(255, 255, 0)
28 #00ffff RGB(0, 255, 255)
29 #800080 RGB(128, 0, 128)
30 #800000 RGB(128, 0, 0)
31 #008080 RGB(0, 128, 128)
32 #0000ff RGB(0, 0, 255)
33 #00ccff RGB(0, 204, 255)
34 #ccffff RGB(204, 255, 255)
35 #ccffcc RGB(204, 255, 204)
36 #ffff99 RGB(255, 255, 153)
37 #99ccff RGB(153, 204, 255)
38 #ff99cc RGB(255, 153, 204)
39 #cc99ff RGB(204, 153, 255)
40 #ffcc99 RGB(255, 204, 153)
41 #3366ff RGB(51, 102, 255)
42 #33cccc RGB(51, 204, 204)
43 #99cc00 RGB(153, 204, 0)
44 #ffcc00 RGB(255, 204, 0)
45 #ff9900 RGB(255, 153, 0)
46 #ff6600 RGB(255, 102, 0)
47 #666699 RGB(102, 102, 153)
48 #969696 RGB(150, 150, 150)
49 #003366 RGB(0, 51, 102)
50 #339966 RGB(51, 153, 102)
51 #003300 RGB(0, 51, 0)
52 #333300 RGB(51, 51, 0)
53 #993300 RGB(153, 51, 0)
54 #993366 RGB(153, 51, 102)
55 #333399 RGB(51, 51, 153)
56 #333333 RGB(51, 51, 51)

RGB-коды можно использовать в VBA Excel наряду с индексами цветов стандартной палитры, а HEX-коды — в HTML.

Процент черного в оттенках серого

Процентное соотношение черного цвета в оттенках серого:

Индекс Наименование Процент черного Оттенок
1 Черный 100%
2 Белый 0%
15 Серебряный 25%
16 Серый 50%
48 Светло-серый 40%
56 Темный уголь 80%

Вывод 56-цветной палитры на лист

Вывод на рабочий лист Excel 56-цветной палитры с помощью кода VBA:

Источник

Наименования цветов стандартной палитры Excel из 56 оттенков на русском и английском языках. Соответствие цветов индексам VBA и их RGB и HEX коды.

Стандартная палитра из 56 цветов — это ограниченная палитра оттенков, которая существовала до версии Excel 2007 года, но продолжает использоваться до сих пор.

За ограниченную палитру в VBA Excel отвечает свойство ColorIndex, которое используется для записи и чтения:

Sub Primer()

    Range(«A1»).Interior.ColorIndex = 10

    MsgBox Range(«A1»).Interior.ColorIndex

End Sub

Свойство ColorIndex принимает и возвращает значения от 1 до 56.

Наименования 56 цветов палитры

Наименования 56 цветов стандартной ограниченной палитры Excel на русском и английском языках:

Индекс Наименование
по-русски
Наименование по-английски Оттенок
1 Черный Black
2 Белый White
3 Красный Red
4 Лайм Lime
5 Синий Blue
6 Желтый Yellow
7 Фуксия* Fuchsia*
8 Цвет морской волны Aqua
9 Темно-бордовый Maroon
10 Зеленый Green
11 Темно-синий Navy blue
12 Оливковый Olive
13 Пурпурный Purple
14 Бирюзовый Teal
15 Серебряный Silver
16 Серый Gray
17 Светло-пурпурно-синий Light purple blue
18 Розовато-лиловый Mauve
19 Бледно-желто-зеленый Pale yellow green
20 Бледно-голубой Pale blue
21 Сливовый Plum
22 Лососевый Salmon
23 Темно-сине-голубой Light navy blue
24 Барвинок Periwinkle
25 Темно-синий Navy blue
26 Фуксия* Fuchsia*
27 Желтый Yellow
28 Цвет морской волны Aqua
29 Пурпурный Purple
30 Коричнево-малиновый Maroon
31 Сине-зеленый Teal
32 Синий Blue
33 Небесно-голубой Vivid sky blue
34 Бледно-голубой Pale blue
35 Бледно-зеленый Pale green
36 Светло-желтый Light yellow
37 Сине-голубой Shade of blue
38 Бледно-пурпурно-розовый Pale magenta pink
39 Светло-сиреневый Light lilac
40 Оранжево-персиковый Peach-orange
41 Светло-синий Light blue
42 Светло-бирюзовый Light turquoise
43 Желто-зеленый Yellow green
44 Желтый мандарин Tangerine yellow
45 Сигнальный оранжевый Safety orange
46 Оранжевый Orange
47 Темно-сине-серый Dark blue gray
48 Светло-серый Light gray
49 Полуночно-синий Midnight blue
50 Зеленая трава Green grass
51 Темно-зеленый Dark green
52 Темно-коричневый Dark brown
53 Темно-красный Dark red
54 Розовато-лиловый Mauve
55 Синий пигмент Blue pigment
56 Темный уголь Dark charcoal

* Вместо термина Фуксия (Fuchsia) можно использовать термин Маджента (Magenta), так как в RGB-модели Фуксия и Маджента являются одним и тем же цветом.

Обратите внимание, что в стандартной палитре Excel из 56 цветов есть повторяющиеся оттенки. Наименования цветов (по их HEX-кодам) подобраны, главным образом, по статьям, опубликованным в Википедии.

RGB и HEX коды оттенков палитры

RGB и HEX коды оттенков 56-цветной палитры Excel:

Индекс Код HEX Код RGB Оттенок
1 #000000 RGB(0, 0, 0)
2 #ffffff RGB(255, 255, 255)
3 #ff0000 RGB(255, 0, 0)
4 #00ff00 RGB(0, 255, 0)
5 #0000ff RGB(0, 0, 255)
6 #ffff00 RGB(255, 255, 0)
7 #ff00ff RGB(255, 0, 255)
8 #00ffff RGB(0, 255, 255)
9 #800000 RGB(128, 0, 0)
10 #008000 RGB(0, 128, 0)
11 #000080 RGB(0, 0, 128)
12 #808000 RGB(128, 128, 0)
13 #800080 RGB(128, 0, 128)
14 #008080 RGB(0, 128, 128)
15 #c0c0c0 RGB(192, 192, 192)
16 #808080 RGB(128, 128, 128)
17 #9999ff RGB(153, 153, 255)
18 #993366 RGB(153, 51, 102)
19 #ffffcc RGB(255, 255, 204)
20 #ccffff RGB(204, 255, 255)
21 #660066 RGB(102, 0, 102)
22 #ff8080 RGB(255, 128, 128)
23 #0066cc RGB(0, 102, 204)
24 #ccccff RGB(204, 204, 255)
25 #000080 RGB(0, 0, 128)
26 #ff00ff RGB(255, 0, 255)
27 #ffff00 RGB(255, 255, 0)
28 #00ffff RGB(0, 255, 255)
29 #800080 RGB(128, 0, 128)
30 #800000 RGB(128, 0, 0)
31 #008080 RGB(0, 128, 128)
32 #0000ff RGB(0, 0, 255)
33 #00ccff RGB(0, 204, 255)
34 #ccffff RGB(204, 255, 255)
35 #ccffcc RGB(204, 255, 204)
36 #ffff99 RGB(255, 255, 153)
37 #99ccff RGB(153, 204, 255)
38 #ff99cc RGB(255, 153, 204)
39 #cc99ff RGB(204, 153, 255)
40 #ffcc99 RGB(255, 204, 153)
41 #3366ff RGB(51, 102, 255)
42 #33cccc RGB(51, 204, 204)
43 #99cc00 RGB(153, 204, 0)
44 #ffcc00 RGB(255, 204, 0)
45 #ff9900 RGB(255, 153, 0)
46 #ff6600 RGB(255, 102, 0)
47 #666699 RGB(102, 102, 153)
48 #969696 RGB(150, 150, 150)
49 #003366 RGB(0, 51, 102)
50 #339966 RGB(51, 153, 102)
51 #003300 RGB(0, 51, 0)
52 #333300 RGB(51, 51, 0)
53 #993300 RGB(153, 51, 0)
54 #993366 RGB(153, 51, 102)
55 #333399 RGB(51, 51, 153)
56 #333333 RGB(51, 51, 51)

RGB-коды можно использовать в VBA Excel наряду с индексами цветов стандартной палитры, а HEX-коды — в HTML.

Процент черного в оттенках серого

Процентное соотношение черного цвета в оттенках серого:

Индекс Наименование Процент черного Оттенок
1 Черный 100%
2 Белый 0%
15 Серебряный 25%
16 Серый 50%
48 Светло-серый 40%
56 Темный уголь 80%

Вывод 56-цветной палитры на лист

Вывод на рабочий лист Excel 56-цветной палитры с помощью кода VBA:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

‘Функция, преобразующая десятичный код цвета в аргументы RGB

Function DecToRGB(ByVal ColDec As Long) As String

Dim r As Long

Dim g As Long

Dim b As Long

    r = (ColDec And &HFF&) 256 ^ 0

    g = (ColDec And &HFF00&) 256 ^ 1

    b = ColDec 256 ^ 2

    DecToRGB = CStr(r) & «, « & CStr(g) & «, « & CStr(b)

End Function

‘Вывод 56-цветной палитры на активный лист

Sub Color56()

Dim i As Integer

    For i = 1 To 56

        Cells(i, 1) = i

        Cells(i, 2).Interior.ColorIndex = i

        Cells(i, 3).Value = «RGB(« & DecToRGB(Cells(i, 2).Interior.Color) & «)»

    Next

End Sub

Процедура Color56 записывает в ячейку первого столбца индекс цвета, ячейке второго столбца присваивается соответствующая индексу заливка, в ячейку третьего столбца записывается RGB-код соответствующего индексу цвета.


Color Palette

Excel’s Color Palette has an index of 56 colors which can be used throughout your spreadsheet. Each of these colors in the palette is associated with a unique value in the ColorIndex. For reasons unknown, aside from the index value, Excel also recognizes the names for Colors 1 through 8 (Black, White, Red, Green, Blue, Yellow, Magenta, and Cyan).
 

interior ColorIndex HTML bgcolor= Red Green Blue Color
Black [Color 1] #000000 #000000 0 0 0 [Black]
White [Color 2] #FFFFFF #FFFFFF 255 255 255 [White]
Red [Color 3] #FF0000 #FF0000 255 0 0 [Red]
Green [Color 4] #00FF00 #00FF00 0 255 0 [Green]
Blue [Color 5] #0000FF #0000FF 0 0 255 [Blue]
Yellow [Color 6] #FFFF00 #FFFF00 255 255 0 [Yellow]
Magenta [Color 7] #FF00FF #FF00FF 255 0 255 [Magenta]
Cyan [Color 8] #00FFFF #00FFFF 0 255 255 [Cyan]
[Color 9] [Color 9] #800000 #800000 128 0 0 [Color 9]
[Color 10] [Color 10] #008000 #008000 0 128 0 [Color 10]
[Color 11] [Color 11] #000080 #000080 0 0 128 [Color 11]
[Color 12] [Color 12] #808000 #808000 128 128 0 [Color 12]
[Color 13] [Color 13] #800080 #800080 128 0 128 [Color 13]
[Color 14] [Color 14] #008080 #008080 0 128 128 [Color 14]
[Color 15] [Color 15] #C0C0C0 #C0C0C0 192 192 192 [Color 15]
[Color 16] [Color 16] #808080 #808080 128 128 128 [Color 16]
[Color 17] [Color 17] #9999FF #9999FF 153 153 255 [Color 17]
[Color 18] [Color 18] #993366 #993366 153 51 102 [Color 18]
[Color 19] [Color 19] #FFFFCC #FFFFCC 255 255 204 [Color 19]
[Color 20] [Color 20] #CCFFFF #CCFFFF 204 255 255 [Color 20]
[Color 21] [Color 21] #660066 #660066 102 0 102 [Color 21]
[Color 22] [Color 22] #FF8080 #FF8080 255 128 128 [Color 22]
[Color 23] [Color 23] #0066CC #0066CC 0 102 204 [Color 23]
[Color 24] [Color 24] #CCCCFF #CCCCFF 204 204 255 [Color 24]
[Color 25] [Color 25] #000080 #000080 0 0 128 [Color 25]
[Color 26] [Color 26] #FF00FF #FF00FF 255 0 255 [Color 26]
[Color 27] [Color 27] #FFFF00 #FFFF00 255 255 0 [Color 27]
[Color 28] [Color 28] #00FFFF #00FFFF 0 255 255 [Color 28]
[Color 29] [Color 29] #800080 #800080 128 0 128 [Color 29]
[Color 30] [Color 30] #800000 #800000 128 0 0 [Color 30]
[Color 31] [Color 31] #008080 #008080 0 128 128 [Color 31]
[Color 32] [Color 32] #0000FF #0000FF 0 0 255 [Color 32]
[Color 33] [Color 33] #00CCFF #00CCFF 0 204 255 [Color 33]
[Color 34] [Color 34] #CCFFFF #CCFFFF 204 255 255 [Color 34]
[Color 35] [Color 35] #CCFFCC #CCFFCC 204 255 204 [Color 35]
[Color 36] [Color 36] #FFFF99 #FFFF99 255 255 153 [Color 36]
[Color 37] [Color 37] #99CCFF #99CCFF 153 204 255 [Color 37]
[Color 38] [Color 38] #FF99CC #FF99CC 255 153 204 [Color 38]
[Color 39] [Color 39] #CC99FF #CC99FF 204 153 255 [Color 39]
[Color 40] [Color 40] #FFCC99 #FFCC99 255 204 153 [Color 40]
[Color 41] [Color 41] #3366FF #3366FF 51 102 255 [Color 41]
[Color 42] [Color 42] #33CCCC #33CCCC 51 204 204 [Color 42]
[Color 43] [Color 43] #99CC00 #99CC00 153 204 0 [Color 43]
[Color 44] [Color 44] #FFCC00 #FFCC00 255 204 0 [Color 44]
[Color 45] [Color 45] #FF9900 #FF9900 255 153 0 [Color 45]
[Color 46] [Color 46] #FF6600 #FF6600 255 102 0 [Color 46]
[Color 47] [Color 47] #666699 #666699 102 102 153 [Color 47]
[Color 48] [Color 48] #969696 #969696 150 150 150 [Color 48]
[Color 49] [Color 49] #003366 #003366 0 51 102 [Color 49]
[Color 50] [Color 50] #339966 #339966 51 153 102 [Color 50]
[Color 51] [Color 51] #003300 #003300 0 51 0 [Color 51]
[Color 52] [Color 52] #333300 #333300 51 51 0 [Color 52]
[Color 53] [Color 53] #993300 #993300 153 51 0 [Color 53]
[Color 54] [Color 54] #993366 #993366 153 51 102 [Color 54]
[Color 55] [Color 55] #333399 #333399 51 51 153 [Color 55]
[Color 56] [Color 56] #333333 #333333 51 51 51 [Color 56]

The values in the above table were generated with help from the following macro.

Sub colors56()
  Application.ScreenUpdating = False
  Application.Calculation = xlCalculationManual
Dim i As Long
Dim str0 As String, str As String
For i = 0 To 56
  Cells(i + 1, 1).Interior.colorindex = i
  Cells(i + 1, 1).Value = "[Color " & i & "]"
  Cells(i + 1, 2).Font.colorindex = i
  Cells(i + 1, 2).Value = "[Color " & i & "]"
  str0 = Right("000000" & Hex(Cells(i + 1, 1).Interior.color), 6)
  'Excel shows nibbles in reverse order so make it as RGB
  str = Right(str0, 2) & Mid(str0, 3, 2) & Left(str0, 2)
  'generating 2 columns in the HTML table
  Cells(i + 1, 3) = "#" & str & "#" & str & ""
  Cells(i + 1, 4).Formula = "=Hex2dec(""" & Right(str0, 2) & """)"
  Cells(i + 1, 5).Formula = "=Hex2dec(""" & Mid(str0, 3, 2) & """)"
  Cells(i + 1, 6).Formula = "=Hex2dec(""" & Left(str0, 2) & """)"
  Cells(i + 1, 7) = "[Color " & i & ")"
Next i
done:
  Application.Calculation = xlCalculationAutomatic
  Application.ScreenUpdating = True
End Sub

Hex equivalents used in HTML

 #000000        #993300        #333300        #003300        #003366        #000080        #333399        #333333      
 #800000        #FF6600        #808000        #008000        #008080        #0000FF        #666699        #808080      
 #FF0000        #FF9900        #99CC00        #339966        #33CCCC        #3366FF        #800080        #969696      
 #FF00FF        #FFCC00        #FFFF00        #00FF00        #00FFFF        #00CCFF        #993366        #C0C0C0      
 #FF99CC        #FFCC99        #FFFF99        #CCFFCC        #CCFFFF        #99CCFF        #CC99FF        #FFFFFF      
  Additional 16 colors below are not shown on the 40 color toolbar palette but can be seen under Format, Cells, Pattern
 #9999FF        #993366        #FFFFCC        #CCFFFF        #660066        #FF8080        #0066CC        #CCCCFF      
 #000080        #FF00FF        #FFFF00        #00FFFF        #800080        #800000        #008080        #0000FF      

Содержание

  • Список кодов индекса цвета VBA
  • Свойство цвета VBA
  • Цвет VB
  • Цвета RGB
  • Список кодов ColorIndex и цвета RGB в Access VBA

При использовании VBA для кодирования Colorindex (или цвета фона) ячейки полезно знать, какое целое число будет равно какому цвету. Ниже приведено справочное изображение, на котором показан цвет и указан соответствующий ему Colorindex. он же Цветовая палитра VBA

Вот код, чтобы сделать его для себя или просто добавить эту страницу в закладки:

123456789101112131415 Sub ColorRef ()Dim x As IntegerДля x = от 1 до 56Если x <ТоCells (x, 1) .Interior.ColorIndex = xЯчейки (x, 2) = xЕщеЯчейки (x — 28, 3) .Interior.ColorIndex = xЯчейки (x — 28, 4) = xКонец, еслиДалее xКонец подписки

Примеры VBA ColorIndex

Установить цвет фона ячейки

1 Диапазон («A1»). Interior.ColorIndex = 6

Установить цвет шрифта ячейки

1 Диапазон («A1»). Font.ColorIndex = 5

Установить цвет границ ячеек

1 Диапазон («A1»). Borders.ColorIndex = 5

Получить индекс цвета фона ячейки

123 Dim col как целое числоcol = Range («A1»). Interior.ColorIndex

Установите цвет фона ячейки на цвет другой ячейки

1 Диапазон («A1»). Interior.ColorIndex = Range («B1»). Interior.ColorIndex

Свойство цвета VBA

Вместо использования свойства ColorIndex Excel / VBA вы можете использовать свойство Color. Свойство Color принимает два типа ввода:

  1. vbColor
  2. Цвета RGB

Мы обсудим это ниже:

Цвет VB

VB Color — самый простой способ установить цвета в VBA. Однако он также наименее гибкий. Чтобы установить цветовой код с помощью vbColor, используйте таблицу ниже:

Однако, как видно из таблицы, ваши возможности крайне ограничены.

Установить цвет фона ячейки

1 Диапазон («A1»). Interior.Color = vbYellow

Установить цвет шрифта ячейки

1 Диапазон («A1»). Font.Color = vbBlue

Установить цвет границ ячеек

1 Диапазон («A1»). Borders.Color = vbRed

Установите цвет фона ячейки на цвет другой ячейки

1 Диапазон («A1»). Interior.Color = Range («B1»). Interior.Color

Цвета RGB

RGB означает красный зеленый синий. Это три основных цвета, которые можно комбинировать для получения любого другого цвета. При вводе цветов как RGB введите значение от 0 до 255 для каждого цветового кода.

Вот пример:

1 Диапазон («A1»). Interior.Color = RGB (255,255,0)

Выше мы установили красный = 255 (максимальное значение), зеленый = 255 (максимальное значение) и синий = 0 (минимальное значение). Это устанавливает желтый цвет фона ячейки.

Вместо этого мы можем установить цвет шрифта ячейки на фиолетовый:

1 Диапазон («A1»). Interior.Color = RGB (128,0,128)

Существует множество онлайн-инструментов для поиска кода RGB для желаемого цвета (вот один).

Список кодов ColorIndex и цвета RGB в Access VBA

Access использует формы для отображения данных. Коды ColorIndex можно использовать для программного изменения цвета фона и цвета переднего плана объектов в формах Access.

12345 Частная подпрограмма cmdSave_Click ()’изменить цвет фона кнопки сохранения при сохранении записи.DoCmd.RunCommand acCmdSaveRecordcmdSave.BackColor = vbGreenКонец подписки

Вы поможете развитию сайта, поделившись страницей с друзьями


Colors

Colors are specified by selection or by using Hexadecimal and RGB codes.


Theme and Standard Colors

Excel has a set of themes and standard colors available for use. You select a color by clicking it:

The «More Colors» option allows you to select custom colors by entering a RGB or HEX code.


Hexadecimal Colors

Excel supports Hexadecimal color values

A hexadecimal color is specified with: #RRGGBB.

RR (red), GG (green) and BB (blue) are hexadecimal integers between 00 and FF specifying the intensity of the color.

For example, #0000FF is displayed as blue, because the blue component is set to its highest value (FF) and the others are set to 00.


RGB Colors

Excel supports RGB color values.

An RGB color value is specified with: rgb( RED , GREEN , BLUE ).

Each parameter defines the intensity of the color as an integer between 0 and 255.

For example, rgb(0,0,255) is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0.



Applying colors

Colors can be applied to cells, text and borders.

Colors are applied to cells by using the «Fill color» function.

How to apply colors to cells:

  1. Select color
  2. Select range
  3. Click the Fill Color button

The «Fill color» button remembers the color you used the last time.

Color options are explored by clicking on the arrow-down icon (),
next to the Fill color command:

The option allows selection of theme colors, standard colors or use of HEX or RGB codes by clicking on the More Colors option:

Colors are made from red, green, blue and are universal. Entering a color in one way will give you the code in the other. For example if you enter a HEX code, it will give you the RGB code for the same color.

Let’s try some examples.

Starting with theme and standard colors:

Great!

Try to apply the following colors:

  • Theme color blue (accent 5) to A3:F3.
  • Theme color green (accent 6) and A5:F5.

Did you make it?

Let’s apply colors using HEX and RGB codes.

Apply HEX code #ffcb05 to A7:F7:

Step by step:

  1. Select A7:F7
  2. Open color options
  3. Click More colors
  4. Insert #ffcb05 in the HEX input field
  5. Hit enter

Notice that applying the HEX code gives the RGB code for the same color, and shows where that color is positioned on the color map.

Apply RGB code 60, 90, 166 to A9:F9

Step by step:

  • Select A9:F9
  • Open color options
  • Click More colors
  • Insert 60, 90, 166 in the RGB input field
  • Hit enter

Notice that entering the RGB code also gives the HEX code and shows you where the color is positioned on the color map.

Well done! You have successfully applied colors using the standard, theme, HEX and RGB codes.


Понравилась статья? Поделить с друзьями:
  • Code listing in word
  • Code in vba for excel
  • Code highlighting in word
  • Code format for word
  • Code for word wrap