Excel colorindex таблица цветов

Наименования цветов стандартной палитры 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-код соответствующего индексу цвета.


Возвращает или задает цвет границы, шрифта или внутренней области, как показано в следующей таблице. Цвет указывается в виде значения индекса в текущей цветовой палитре или в виде одной из следующих констант XlColorIndex: xlColorIndexAutomatic или xlColorIndexNone. Для чтения и записи, Variant.

выражение. ColorIndex

выражение (обязательно). Выражение, возвращающее один из объектов списка Применяется к.

Это свойство указывает цвет в виде индекса в цветовой палитре. На рисунке ниже показаны значения цветового индекса в цветовой палитре по умолчанию.

В следующих примерах предполагается, что используется цветовая палитра по умолчанию.

В этом примере устанавливается цвет основных линий сетки для оси значений.

В этом примере устанавливается красный цвет внутреннего заполнения диаграммы и синий цвет для границы.

Если вы хотите использовать цвет с объектом FormatCondition в Visual Basic, ознакомьтесь со статьей Свойство Interior.ColorIndex.

Есть вопросы или отзывы, касающиеся Office VBA или этой статьи? Руководство по другим способам получения поддержки и отправки отзывов см. в статье Поддержка Office VBA и обратная связь.

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

This example sets the cell’s background color.

This example sets the cell’s font color.

This example sets the cell’s border color.

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

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

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

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.

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.

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.

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

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.

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.

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

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

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

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

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

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

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

Excel Color Index, coloring of fonts, cell interiors [palette], [copy], [chart], [colorindex], [grayscale], [formatting], [DOS/OE], [HTML]*, [Help], [Macros], [macros], [ColorFormulas], [FormatUnprotected], [chgfont], [ClearConstantsf], [icolorF], [popvalue], [popbased], [sorting], [count], [rowcolor], [DelRows], [hexconv], [chgpalette], [fillcolor], [cellcommentcolor], [BackupDisplay], [tabs], [triangles], [manual], [colorcharts], [detector], [Luma], [pgms], [colorcoding], [coloringcode], [VBE], [Related], [thissite], [postings], [otherxl], [other], [font], [problems], [printers], [mskb], [msdn],

Scope of the Color Palette: Each workbook has it’s own palette. To change the default, change your book.xlt template for new workbooks.

When you change a color in the palette, it is changed for any element formatted with the color you changed, throughout the entire workbook. To use the same custom color scheme in a set of workbooks, you can copy the color palette from one workbook to another. For example, you can create a custom color palette that matches your company’s logo and image and then copy it into the workbooks used in company presentations. You can also replace the default color palette that Microsoft Excel uses when it creates a new workbook.

Note: I have not had any desire to change my own colors so expect them to be unchanged. Correct interpretation of the 56 colors in the ColorIndex is dependent upon the HTML wizard conversion on ColorIndex numbers. The RGB values definitely match color swatches.

The names for colors appears to have a wide variance; I am trying to find what Microsoft generally calls them if they are not named in Excel.

The following colors has been used in Microsoft KB documentation probably for the first 16 colors:
Black, Blue, Cyan, Green, Magenta, Red, Yellow, White, Dk Blue, Dk Cyan, Dk Green, Dk Magenta, Dk Red, Dk Yellow, Dk Gray, Lt Gray More confusion found in MS KB documentation 0 — Black, 1 — Blue, 2 — Green, 3 — Cyan, 4 — Red, 5 — Magenta, 6 — Yellow/Brown, 7 — White, 8 — Gray,
9 — Bright Blue, A — Bright Green, B — Bright Cyan, C — Bright Red, D — Bright Magenta, E — Bright Yellow, F — Bright White

I have had to change some colors to match Microsoft usage from what I thought was normal usage. Assignment of name Gray may have to be changed. Color6 and Color27 appear to both be Yellow on my system even after resetting colors (Tools —> Options).

It would be hard to compare the palettes between XL95 and XL97. The XL95 palette is arranged by index number and the XL97 palette is arranged chromatically.

to see the palette in Excel
40 color palette is on a toolbar icon
56 color palette is available with Format, Cells, Patterns(tab)

in VBA
Application.CommandBars(«Fill Color»).Visible = True ‘ — 40 colors
Application.Dialogs.Item(xlDialogColorPalette).Show ‘ — 56 colors

This table was NOT generated by the Internet Assistant Wizard for Microsoft Excel. You can find this add-in on «http://www.microsoft.com/msoffice/freestuf/msexcel/index.htm» —>

Appearance of table redone 2000-12-09 in Excel 2000, I display 32,760 colors, Excel shows only 56 colors at any time. Following are the defaults.

The following color pairs are the same color
11 & 25, 5 & 32, 14 & 31, 8 & 28, 9 & 30, 13 & 29, 18 & 54, 20 &34, 7 & 26, and 6 & 27.

The above table was created in Excel 2000 with help from the following macro, which includes Worksheet function HEX2DEC. The table was converted to HTML using XL2HTML macro which (at least when done) does not convert embedded HTML code within a cell.

The default ColorIndex numbers can be found in HELP —>. Index —> ColorIndex Property

The colors names indicated on the color palette are for descriptive purposes only. Excel only recognizes names for Color 1 through 8 (Black, White, Red, Green, Blue, Yellow, Magenta, and Cyan).

The parts of the format (unless changed) are:
positive numbers; negative numbers; zero; text

For more information on formatting see your Excel HELP and my Formula page and particularly Custom Cell Formatting.

-4 [>=5]General; [Red]-General; [Blue]General
-1 [>=5]General; [Red]-General; [Blue]General
0 [>=5]General; [Red]-General; [Blue]General
2 [>=5]General; [Red]-General; [Blue]General
4 [>=5]General; [Red]-General; [Blue]General
5 [>=5]General; [Red]-General; [Blue]General
10 [>=5]General; [Red]-General; [Blue]General
txt [>=5]General; [Red]-General; [Blue]General
Entry Formatted Format — GetFormat(cell) was used to display Format
-7 — 7.00 [Blue][>=5]0.00; [Red][ — 3.00 [Blue][>=5]0.00; [Red][ — 2.00 [Blue][>=5]0.00; [Red][ — 1.00 [Blue][>=5]0.00; [Red][ 0.00 [Blue][>=5]0.00; [Red][ 1.00 [Blue][>=5]0.00; [Red][ 2.00 [Blue][>=5]0.00; [Red][ 3 [Blue][>=5]0.00; [Red][ 4 [Blue][>=5]0.00; [Red][ 5.00 [Blue][>=5]0.00; [Red][ 6.00 [Blue][>=5]0.00; [Red][ 7.00 [Blue][>=5]0.00; [Red][ Text:Test [Blue][>=5]0.00; [Red][

Pastel colors for 50% backgrounds HTML (#chrome)

FEF5A8 C5F19A FFD8A0 F5DDB7 B9D0E8 D6BFD4 F79494 D3D7CF
template_talk
#FFFFCC #FBF4D4 #FFFF80 #F3E078 #B3B300 #BFCFFF #CCCCFF #F3E0FF #DCFFDC

Changing the Colors of your DOS session (#DOS)

Color change is available at least in WinNT.

Changing colors of your DOS window may or may not work for you. I changed mine mainly in order to work with a specific package so that the wording is black on white. This is easy to change but where there is no text the color will remain black. (directions). Color can also be changed in the DOS window with the color command (Color F0), which can be put into your Autoexec.bat — to be effective you must reboot. The screen can still turn black upon exiting an application but can be instantly reverted to white by typing Color.

The DOS assignments of the 16 colors (0-15) (#OE)

The normal VGA assignments do not apply to Excel, but they do apply to older VGA monitors used on IBM mainframes and DOS color assignments.

0 1 2 3 4 5 6 7
000000
Black
000080
Navy
008000
Green
008080
Teal
800000
Maroon
800080
Purple
808000
Olive
C0C0C0
Silver
The assignments 0-15 are NOT those used by Excel ColorIndex
10 11 12 13 14 15
808080
Gray
0000FF
Blue
00FF00
Lime
00FFFF
Cyan*
FF0000
Red
FF00FF
Magenta*
FFFF00
Yellow
FFFFFF
White

The Colors supported by Internet Explorer and most browsers in alphabetical order (#HTML):
AQUA , BLACK , BLUE , FUCHSIA , GRAY , GREEN , LIME , MAROON , NAVY , OLIVE , PURPLE , RED , SILVER , TEAL , white (white), yellow [Select area with mouse to read]

The above colors are supported in the HTML 3.2 standard but have not been universally accepted by all browsers. In HTML the colors are Fuchsia: #FF00FF instead of Magenta; and Aqua: #00FFFF instead of Cyan.

#gamma
The colors above and as fonts below are the choices of colors for Outlook Express and use the HTML names. Colors 0-6, and 8 are very hard to see the difference looking straight at the screen on what would now be an old laptop.

0 Black , 1 Navy , 2 Green , 3 Teal , 4 Maroon , 5 Purple 6 Olive , 7 Silver ,
8 Gray , 9 Blue , 10 Lime , 11 Aqua+ , 12 Red , 13 Fuschia , 14 Yellow , 15 White

0 Black , 1 Navy , 2 Green , 3 Teal , 4 Maroon , 5 Purple 6 Olive , 7 Silver ,
8 Gray , 9 Blue , 10 Lime , 11 Aqua+ , 12 Red , 13 Fuschia , 14 Yellow , 15 White

0 Black , 1 Navy , 2 Green , 3 Teal , 4 Maroon , 5 Purple 6 Olive , 7 Silver ,
8 Gray , 9 Blue , 10 Lime , 11 Aqua+ , 12 Red , 13 Fuschia , 14 Yellow , 15 White

0 Black , 1 Navy , 2 Green , 3 Teal , 4 Maroon , 5 Purple 6 Olive , 7 Silver ,
8 Gray , 9 Blue , 10 Lime , 11 Aqua+ , 12 Red , 13 Fuschia , 14 Yellow , 15 White

You should be able to distinguish link colors, if you can’t, consider specifying your own default colors (or even overrides). Click here to establish visited links below.

Possible link
color changes
link #0000FF
visited #FF00FF
link #0000FF
visited #FF00FF
Your own
link colors
unvisited link
visted link
unvisited link
visted link

You can change your own default colors for links:
In Internet Explorer use Tools, Internet, General (tab), Fonts.
(Not recommended but Accessibility button has option to override web page colors.)
In Firefox use Tools, Options, General (icon on left), Fonts and Colors, OK. (color override on same dialog.)

To temporarily override a web pages visited links color you can use a bookmarklet which would be in effect until you reload the page or hit F5 (Reset/Reload). The bookmarklet Links Visited to RED is particularly useful when viewing Google search results. (Try it yourself, and Reset with F5. If you like it drag to links bar or a folder in your links bar, and do look at my bookmarklets page.)

Since changing the actual colors is not possible, and would be ill advised, I’m not going to attempt to see if it is possible to have eight distinguishable font colors for my laptop when within Outlook Express usage.

The Gamma can be changed for colors, and is somewhat equivalent from moving up or down when viewing the laptop monitor, or by adjusting the tilt of the monitor. Most of problem distinguishing color pertains to fonts, backgrounds are okay and bold text better than plain text. To adjust the colors on the monitor use: Control Panel, Settings, Display (monitor), settings (tab), Advanced (button), Color (tab), and change the color. The gamma is seen as a color curve that you can distort for each of the primary colors (Red, Green, Blue). Other Display settings.

HELP —> Find —> color —> color —> «Basic number format codes»

HELP —> Index —> colorindex property —> colorindex property

Setting Colors in Excel VBA Macros (#macros)

Coloring Formulas Blue, and remove other font colors (#ColorFormulas)

You could assign this to a toolbar button. Also see Coloring Cells based on CellType as tested with SpecialCells.

Coloring Unprotected Cells Blue (#FormatUnprotected)

Simulate a Lotus 1-2-3 feature to color unprotected cells blue (ref)

Changing Font based on interior color and column (#chgfont)

Check for interior color of 41 (light blue).

Clear Constants from Color Cells (#ClearConstantsFromColorCells)

You can select an entire column without taking 6 seconds to process every cell in that column because the cells processed must also have constants. Anything located by SpecialCells is by definition in the UsedRange. Anything outside the UsedRange could have color but won’t have constants.

Have been doing so many change events lately that I turned off events during the execution. There is a little risk here with EnableEvents turned off should the subroutine fail for some reason.

Determining Interior Color of Another Cell (#icolorF)

You won’t get too far in HTML using range.Interior.Color as above which is supposed to show RGB but shows them in the wrong order and without leading zeros. HTML has the RGB components in the correct RGB order, so the following would be what you need to equate to HTML color definitions. Most people get the HTML wrong because range.Interior.Color returns wrong order for RGB components. For this reason the tables show the #prefix used in HTML colors to avoid all ambiguity.

The shortcut key Ctrl+Alt+F9 forces a recalculation of *everything* in all open workbooks whether or not Excel *thinks* recalculations are needed. Changing a format does not trigger cell recalculation, so you will have to force this when you want the values to change.

The use of Volatile would also work but would probably have a severe impact on your use of Excel. the VBA equivalent of the shortcut is
Application.CalculateFull ‘ in Excel 2000

Coloring a selection based on a simple cell formula (#colorofassignment)

See posting 2005-06-01 in Excel.misc

A B C D E
1 A1-1 A1-1 C1: =A1 also tested for formulas like:
2 A2-1 A3-1 C2: =A3 =Sheet4′!A18
3 A3-1 100 C3: =A4 =’Sheet four’!A18
4 $100.00 A2-1 C4: =A2 =(D20)

Formatting a selection based on a simple cell formula (#formatofassignment)

See posting 2005-06-01 in Excel.misc

A B C D E
1 A1-1 A1-1 C1: =A1 also tested for formulas like:
2 A2-1 A3-1 C2: =A3 =Sheet4′!A18
3 A3-1 $100.00 C3: =A4 =’Sheet four’!A18
4 $100.00 A2-1 C4: =A2 =(A20)

Populating cell value based on Cell Interior Color (#popvalue)

Setting Interior Color based on another Cell (#popbased)

Sorting on Interior Cell Color (#sorting)

This is a somewhat frequent request, that is going to be prone to errors in interpretation of what color is. You can obtain ColorIndex or RGB but how would you sort that meaningfully. Finally you are going to have problems with recalculaton.

This topic is covered further on a separate page: Color, Sorting on Color

Interior Color, using Count, SUM, etc. (#count)

  • ShowColor(cellref) — Patrick Molloy
  • If the colors you want to test are due to Conditional Formatting then use the same kind of test that you used for Conditional Formatting, and the results will be immediate (no recalculation needed) i.e.
    =COUNTIF(D12:D16,TRUE)
    =SUMIF(D12:D16,TRUE,E12:E16)

    If the colors are not from C.F. you will have to use a User Defined Function to find this information and since formatting is not registered as a cell change you will have to wait for a recalculation to occur to get a valid answer. You can but should not make the macro Volatile, since by doing that you could bring your Excel to an extremely slow state. Examples follow in the next paragraph.

    See my Functions for Determining Interior Color of Another Cell described earlier for RGB, ColorIndex, and HEX.

    Chip Pearson has some additional color functions using a little different approach unfortunately for whatever reason he does not provide (#cpcolorsx) examples of his Functions For Cell Colors:

    The following examples obtain the colorindex from another cell which is best, because colorindex colors can be changed by changing the palette.

    Interior, colorindex of
    =cellcolorindex(A$3,0)
    if you installed in your personal.xls workbook to be available to all workbooks, use
    =personal.xls!cellcolorindex(A$3,0)

    Font, colorindex of
    =cellcolorindex(A$3,1)

    Count the cells with same interior color as A$3
    =countbycolor(A$1:A$17,cellcolorindex(A$3,0))

    Count the cells with same font color as A$3
    =countbycolor(A$1:A$16,cellcolorindex(A$3,1),1)

    Sum of the cells with same interior color as A$3
    =sumbycolor(A$1:A$16,cellcolorindex(A$3))

    #NAME? error will occur if you misspell one of the UDF (User Defined Function) above or did not install the function. A #VALUE! error may occur if you did not install a function used inside or misuse it. Instructions to install macros and User Defined Functions can be found on my formula.htm page.

    To work with shading instead of colorindex use .pattern instead of .colorindex and rename functions accordingly. Specific patterns include such name as: xlgray8, xlgrid, xlvertical

    Processing Coloured Cells, Bob Phillips, informative text, and macro subroutines

    Determining the Row color based on cell value in that row (#rowcolor)

    Conditional Formatting introduced in Excel 97 is limited to 3 conditions. With more than 3 conditions a macro would be required, such as shown below. Another kind of macro that you could use is an Event Macro. Note even if you have an Event macro you will probably want a normal macro to fix things up ahead of time. A more complicated macro differentiating text values, numbers, and empty cells in addition to ranges of numbers.

    Delete Rows Based on RED interior color in Column A (#DelRows)

    The following will delete the entire row if it sees RED as define by ColorIndex = 3 There are some caveats:

    • Conditional Formatting colors are invisible to VBA.
    • The ColorIndex = 3 is the default someone could change it
    • Not everybody is going to be able to distinguish RED from colors close to it and then there is Red/Green colorblindness.
    • Not all monitors are going to show colors alike, though RED is pretty safe in that regard.

    Comments for the following code can be found below the macro DelCellsUp on another web page.

    HEX Conversions for RGB values (#hexconv)

    Hex characters are actually characters, but represent binary numbers.

    RGB values are represented by 6 hex digits. The first pair of digits represents Red, the next Green, and the last Blue. The values range from 0 to 255, or in hex from 00 to FF. Given a six hex digit representation in hex characters such as 00C0C8 as hex characters simply use left, and mid to separate them the digit pairs. Look in HELP for more information about HEX2DEC and DEC2HEX. Suppose B14 had a Long (Binary) integer in it and you want 6 hex digits for RGB. HEX2DEC and DEC2HEX are part of the Statistical Analysis Toolpak [menu] [list]

    There are 256³ RGB colors (16,777,216) and only 56 colorindex colors in the palette; so a one to one match of each is not only impossible, but the colors in the palette can be reassigned to different colors.

    Conversion of Font color in Excel to a hex string for HTML (via VBA code) (#hexconvxl)

    The following code was used in XL2HTMLx conversion of an Excel sheet to HTML. Note Excel appears to store binary values in reverse order or perhaps this is just “big-endian” (main frames, 1234 order) vs. “little-endian” (most PCs, 4321 order). Conversion of a single binary decimal number to decimal RGB components (WS formulas) If you have a character value such as 00C0C8 or you start from a Long (Binary) integer, your can incorporate the above formula into the following

    I have not provided for the possibility of 3-digit hex numbers in HTML like #333 #608 which are equivalent to #333333 and #660088, simply because I would never create the values that way myself.

    I also would never produce RGB(red,green,blue) strings for use in HTML and they are mostly done incorrectly (without quotes) in most places that I see them used and harder to work with visually when coding or comparing source.

    Changing the Colors of your Excel Color Palette (#chgpalette)

    To change a color in your palette go to Tools —> Options —> Color where you can change a color by double-clicking on a color cell. Use Reset to revert back to defaults. Also see Help —> colors, changing

    Changing the default Shading Color (Fill Color) / (#fillcolor)

    The default shading color is yellow (RGB: 255, 255, 0). If you want to change it for a workbook you will have to change the color in that position of the palette. Best to exchange the color with another color on the palette say Lt Green (RGB: 204, 255, 204) using Tools, Options, Colors, Modify, Custom. You can always use Reset to restore normal palette for the workbook.

    A frequent question in the newsgroups is how to change the default colors in the Cell Comments. The name of the author is picked up from your Tools, Options, General, User Name. (you cannot change the color of the red triangle)

    Cell Comments are Tool Tips so to change your default you must change your Windows default. To change only once cell comment double-click on the border of the cell comment and make your changes.

    To change Tool Tips. (Changes to Windows settings affect ALL applications)
    Windows START, settings, control panel, Display (monitor icon)

    Retain a copy of your Original Control Display Settings (#BackupDisplay)
    Before continuing it might be a good idea to name your current settings and then name your new settings.

    • Press [Save As] button then assign the scheme to something like Windows out of the box mmm dd, yyyyy (current date).
    • Press [Save As] button then assign your own name to the scheme i.e. “David 2000-06-22”, and all future changes would be made to this scheme.
    • In the item: pull down, rather than pulling down you can simply place cursor in the box and then use the cursor to cycle up or down through the choices. Select “Tool Tip” and make changes to font, fontsize, text color, background color as wanted. not sure if you actually will change the fontname or not.

    You can select parts of the windows shown which will change the item selected, but tool tips is not one of them, you have to use the pull down.

    My own settings show: red text, yellow background, 8 point, MS Sans Serif, non bold, non italic. (I’m not sure what they were originally).

    More material on Cell Comments

    Changing the Colors of Worksheet Tabs (#tabs)

    The color of the tabs is controlled by Windows, you can change the scrollbar setting but it will affect everything in Windows and until Excel 2002 all tabs had to be the same color as the scrollbar. Changes to size of scrollbar will change size of tabs. Changes to color affect both tabs and all scrollbars in Windows (or at least in Office). You can change the fontsize on the sheet tab, but not the font color or font size within the sheet tabs. Before making changes see Retain a copy of your Original Control Display Settings on this page.

    In Excel 2002 you can color individual worksheet tabs. Here is a tip from Jessica Kovalik in exceltip at Microsoft ’s Office site.

    • Select the sheets you want to color by holding down the CTRL key and clicking the tabs.
    • On the Format menu, point to Sheet, and then click Tab Color. You can also right-click the sheet tab and then click Tab Color.
    • Click the color you want, and click OK.

    In VBA (for Excel 2002) the equivalent would be:
    Activesheet.Tab.ColorIndex = 50

    I believe the normal reason to color tabs is to provide an organization to them. You can sort sheet tabs with a macro. You can enhance your sorted arrangement by preceding the sheet tab with some less conspicuous small letters prefixes. i.e.
    k.FunctKeys, k.ShortCutKeys
    If working with dates for sheetnames, spell the year out and place it first
    2002-10, 2002-11, 2002-12, 2003-01
    sort sheet tabs into alphabetical order in http://www.mvps.org/dmcritchie/excel/buildtoc.htm#sortallsheets
    The main topic on that page is to create a Table of Contents with hyperlinks to the other sheets. Shorter versions with just membernames can be found in buildtoc.htm. A builtin alternative to navigate to a sheet via the More Sheets dialog listing (also available from a macro) is to right-click on a scrolling arrow in lower left corner, the sheets are listed in the same order as the worksheet tabs at the bottom of your spreadsheet (another reason to sort your worksheets).
    Sort sheets by color of sheet tab, by colorindex number, Chip Pearson’s sortws.htm

    There is one problem that I know of with the arrangement of sheet tabs. You will probably have trouble with Mail Merge if the worksheet to be used in Mail Merge is not the first worksheet.

    You can go through 90 worksheets very quickly using Ctrl+PageDn to go down through the worksheet tabs, or Ctrl+PageUp to backup through the tabs. I prefer to use a couple of macros and toolbar buttons –

    Color Triangles in Excel (#triangles)

    • Red , upper-right corner of a cell indicates a Cell Comment
    • Black, upper-left corner of a cell indicates highlight changes: Tools, Track changes, Highlight Changes
    • Green, upper-left corner of a cell indicates a potential error in the formula in the cell. To turn off or adjust settings: select Tools, Options, and select the Error Checking (tab) and uncheck «Clear the Enable Background Error Checking». [new in Excel 2002 (dead link at MS]and you can change the color of error indicator triangle there as well. Not shown if Track Changes is also in effect.
    • Purple, lower-right corner of a cell indicates a smart tag. [new in Excel 2002 (XP)] to turn off or adjust settings: select Tools, Options, and select the Error Checking tab. [more]

    Printing the comment indicator by aligning a shape over the upper right corner of cells with comments. see Print Worksheet with Comment Indicators (contextures.com)

    Manually Changing the Interior Color of Worksheet Cells (#manual)

    Setting the interior color of the active cell, specifically Applies to all cells in a selection that you can add to with the use of the Ctrl key.
    Format —> cells —> patterns and colors

    You can install a button on your toolbar to hasten the process, it looks like a dripping paint can.
    View —> customize —> toolbars —> custom —> format
    select the dripping paint bucked, marked Fill Color and drag it to your toolbar (if not already there).

    Color Coding Cells for Usage (#colorcoding)

    You can color code cells or text to help with reading and/or to help with data entry. Please keep in mind that laptops and color-blind people may not see colors the same as you do.

    • Pale color shading can be used to designate input areas, and can be expanded to different colors for input from different areas (departments).
    • Formula results might be shown with a different text color, and the formulas themselves and other non-input areas such as descriptions might be protected from accidental changes.
    • Cells with links will generally show up in blue or purple with underlining. Best not to change what people expect.
    • Highlight cells for review that you modified or find questionable. Change them back at a later time. Also see tracking in Highlight changes.

    Related: Conditional Formatting, Format/Styles, Filtering, Tracking

    Color Charts on the Web (#colorcharts)

    Hex Color Chart for the HTML Resource Guide for a faster loading variation of Jacobson ’s hex chart by Jack Wilson. [ http://www.bitmedia.com/colors/ ] It ’s faster because it uses tables with BGCOLOR instead of a lot of bit maps. [ archived copy]

    Color Chart at Alan Barasch ’s Excel site has a slider to change the background color so you can check combinations of cell colors in foreground to varied background colors in HTML. Pretty neat. He also has a similar Font Color Chart (text background), and Color Chart (page background) a slider to change cell background color. (Charts and sliders each have 216 colors) Works only in Internet Explorer, but is one of the easiest to use.

    Color Detector (#detector)

    cosmin.com — Color Detector, Freeware program to detect the color of any pixel on the screen. Simply run the program, point the mouse cursor anywhere on the screen, and the color detector window will display the RGB values, HTML hex code, and the color name of the color of the pixel pointed to by the mouse cursor. You can invoke the installed .exe link directly with IE, or if using Firefox by invoking through your customized Launchy extension to invoke with Explorer. ( colordector.exe)

    If you are using Firefox for browsing HTML you might want to also install Colorzilla extension for working within Firefox – Eyedropper (color sampler, status bar options), ColorPicker, Page Zoomer, DOM inspector (if present). More extensions on my Firefox Customization (Notes) page.

    Color Wheel Picker, is similar to Color Detector but works only on its page with a color wheel so you can pick your color (IE active-x only)

    Back To Font Web Color Picker, select your colors and create the styles to place into your HTML coding. Also see CSS (Style Sheets) on other references on my Font page.

    HTML Colors — Color picker, AMPsoft, displays the hex, dec and RGB values, via taskbar icon or hotkey (is not a detector)

    Palette Grabber :: Firefox Add-ons, Creates a color palette for Photoshop, Paint Shop Pro, GIMP, Flash, Fireworks, Paint.NET, or OS X based on the current page.

    Color Luminance (#Luma)

    In color television luminance is calculated (approximately) like this (1 = white, represented by 1V signal voltage):
    L = R*0.3+G*0.59+B*0.11

    This formula was created to make the color video signal compatible with black and white monitors/receivers. Monochrome monitors are still in use as professional viewfinders on many TV cameras, since they create a sharper image than one made from a color matrix. Posted by Harald Staff, plus the reference below.

    Colors used in other programs (not Excel) / (#pgms)

    • Color Cube (geocities archive), see The JavaScript Source: Image Effects: Basic Color Cube. Show what different background colors (in HTML) would look like from a choice of 216 (18×12) colors.
    • Syd Allan: HTML Tag an Color Test Page, has a list of other sites with color information, and has color tables of colors used in SAS.

    Coloring Code (#coloringcode)

    • Pretty Print printing VBA Code in colors as you see them on your screen.
    • HTML Kit also has color provisions and is set up for HTML. HTML-Kit described in Related area of my Excel to HTML page.

    Colors used in the Visual Basic Editor (#vbe)

    Not going to go into this in detail here or on the page for the Visual Basic Editor (VBE) Window but you can change the colors in the code window (Alt+F11, F7) for background, font and indicator for each of these texts: Normal, Selection, Syntax Error, Execution Point, Break Point, Comment, Keyword, Identifier, Bookmark, and Call Return. [VBE Tools menu, Options, Editor Format (tab) ]

    Browsers ☷ ☷ ☷☷

    There are bookmarklets (JavaScript code) that are stored as bookmarks that can be run in all browsers, but specific bookmarklets may be limited to one browser due to limitations in a browser. There are several webpages with bookmarklets that involve color at squarefree.com, specifically Color Bookmarklets and Bookmarklets for Zapping Annoyances.

    Pages on this site using Color (#thissite)

    • Color, Sorting on Color
    • Coloring within Ranges, Examples
    • Conditional Formatting,
      Finding Conditional Formatting Formulas afterwards (—identify—); CondFormula macro also on Formula page.
    • Event macros, example for change event using Case statement makes use of colorindex and refers back to this page.
    • Excel to HTML conversions, macros XL2HTML, XL2HTMLx and other, along with references to other HTML materials, and conversions.
    • Font
    • Formula page, Custom Formatting (custom number formatting), and also seen above on this page.

    Newsgroup Postings on Colors (#postings)

    • Coloring Capital Letters within a cell, posting by Mike Currie, 2002-12-19, in excel.misc, colors capitals Red [3], non-capitals as black [lowercase and digits with 1] and error cells with Teal [14] using a Change Event macro, I included a comparable ColorCapsCatchUp macro for use on existing cells prior to installing the Change Event macro. You can search Google Groups for the string Characters(Start:= for additional examples of formatting or coloring parts of text strings.
    • Coloring for Day of Week in a Macro, Bob Phillips, 2004-01-25.
    • RGB Colors posted collection of links by Tom Ogilvy (2000-05-10). — and it doesn’t even have the varied names of colors recognized by some of the browsers.
    • Showing the Color dialog, showing the user assigned colors

    Other Pages on Colors in Excel (#otherxl)

    • Chip Pearson ’s «Functions For Cell Colors». Nice functions but no examples there, see my examples above.
    • Conditional Chart Examples, Jon Peltier, how to change the formatting of a chart ’s plotted points (markers, bar fill color, etc.) based on the values of the points
    • Excel code to modify Excel chart palette colors — The PowerPoint FAQ, Brian Reilly. The supplied code are mostly variations of black to point out that excel is not applying the actual RGB but the ColorIndex. (archive 2001-12-22, posted).
    • Colour Palette Tool, Ed Ferrero, to modify the colour palette, and save it as a small file that can be distributed (newusers, 206-02-15).

    Colorblind (#colorblind)

    • How do things look to colorblind people?
    • ColorBrewer, by Cindy Brewer some color schemes for color separations as on maps (qualitative), as on population densities (sequential), as emphasis on low and high values as in ages (diverging). Shows whether good for color-blind, photocopy, LCD projector, CRT-friendly, printer friendly. For what I tried, the choices are so distinct that I did’t see any problems on my laptop (32 bit color) even though marked as not good for laptops. [color choices, also see Jenks below] — Maybe I can’t find what I thought was there
    • Vischeck: VischeckURL, color blindness check of your designated web page (URL) as seen by someone with Deuteranope (a form of red/green color deficit), Protanope (another form of red/green color deficit), Tritanope (a blue/yellow deficit- very rare). Look further into site and the numbers are adjustable for further testing. The displays on this site use technology licensed by Stanford University.
    • Color Scheme Designer 3, Simulate color vision deficiency.

    Other Pages Making Use of Color (#other)

    • Changing Font color for certain words within a cell, Dave Peterson, macro, 2003-05-28 [also see Font page]
    • Color, Sorting on Color, not recommended, at least not in any Excel through Excel 2000, but the topic does come up.
    • A Color Picker Dialog Box, John Walkenbach, Tip49. An alternative to not being able to determine the current selected color in the color palette dialog boxes (xlDialogColorPalette).
    • Coloring within Ranges, Examples
    • Color Palette Generator, degraeve, Enter the URL of an image to get a color palette (10 colors) that matches the image. Useful in creating a website color palette that matches a key image to be used for a website. [referened by Favicon Generator]
    • Color Tools, links provided at Univ. Of Minnesota
    • Conditional Formatting was introduced with Excel 97 and is a terrific feature, but there is a limit of 3 conditional sets per cell grouping (like 3 wishes). Conditional Formatting, while in effect for a cell, will override the text colors that can be produced for numeric values by normal cell formatting.
    • Conversion to Grayscale, a chapter in a book available online about color Grokking the GIMP by Carey Bunks.
    • Jenks Natural Breaks, part of the Virtual Geography Department Project described in Cartography Working Group of the Department of Geography, Dartmouth College.
    • Logos and Graphics into headers/footers, you can assign the top rows of your spreadsheet for use as headers to include logos, logos in color, and to include fonts in color. Fonts are available only in one color in the actual headings and footings— black. For footers you are out of luck as far as alternatives to black.
    • Office 2007: Using Color in Excel and PowerPoint, 2007, Excel and PowerPoint provide a number of common colors for quick access from the FILL buttons on the Ribbon. If you prefer to use a different color or a customized color from the dialog color box.
    • Security hardware encryption, terms for similar information: cryptography, encryption, stenography, digital watermarks
    • Restore Hyperlink Style, restore normal hyperlink colors and formatting
    • Rowliner « , Chip Pearson. RowLiner add-in allows you have Excel automatically draw row and/or column lines around the active cell, making it easier to view rows and columns, especially when gridlines are not visible. But you lose the ability to use undo (Ctrl+Z) with macros and with addins.
    • Setting Colors and Safe Colors in HTML, Dave Raggett’s Introduction to CSS (Cascading Style Sheets)
    • Using Colors in Excel Charts, PTS Blog, Jon Peltier by Jon Peltier
    • Worksheet Change Events, shows changing color of cells upon Change.

    Problems formatting color (#problems)

    • Can’t see font on a black background: When formatting Cell Comment or Text Box format the FONT from the Font tab, changing the line color under the Color Tab will not affect the font. (2004-03-31, McRitchie, misc)
    • Printer out of a color of ink.
    • File, Page Setup, Sheet, Print B&W — will remove interior color, and will print font, and borders in black. Print Preview shows up same as Printed copy (in black and white).
    • Use of a template such as book.xlt and sheet.xlt
    • Use of Format, Style can seem like a template was used to set up colors, but can’t find any such format. Format, Style, should be normal and no shading
    • Colors are only missing on monitor, due to High Contrast Accessibility option. A variation of same problem: The fill color, the fill pattern, or the line color of a WordArt or AutoShape object in an Office document does not change
    • Also see companion page – Colors as seen on Monitor, and in Preview and Print, which attempts to show what you might see.
    • You see a lot of gray (grey) on the sheet and you may see big page numbers. That would be page break Preview, eliminate with Eliminate with View, Normal
    • Excel 2003 apply the Service Pack, can’t find anything on printing problems, but have been told it fixes some kind of problem. Always be sure to keep your software updated. Description of the Excel 2003 post-Service Pack 1 hotfix package: February 20, 2005. Though there is a scaling problem with margins print 1 pages wide by 1 pages tall.

    Printers, Printing and colors — How Printers work (#printers)

    Microsoft Knowledge DataBase (#mskb)

    Q97600 Printed Colors Different than on Screen: Blue is Purple, etc. This is not a problem with your printer driver, with Microsoft Windows, or with your printer. RGB colors (light) are additive. CMYK colors (pigments) are subtractive. Color-Matching Blues [PC Magazine Apr 9, 1996].

    Q149170 — Sample Visual Basic Code to Create Color Index Table
    http://support.microsoft.com/?id=149170

    Q170781 XL: RGB Function May Map to Incorrect Color
    The color property accepts an RGB triple and maps it to the nearest color index. When the property retrieves the color value, it returns the RGB color of the index, which may be different from the value you typed. In the example, RGB(65,0,0) is mapped to Dark Red (RGB(128,0,0)), but RGB(64,0,0) is mapped to Black (RGB(0,0,0)).

    Q157202 — XL97: Color Palette Looks Different in MS Excel 97
    http://support.microsoft.com/?id=157202
    Q211533 — XL2000: Color Palette Looks Different in Microsoft Excel 2000
    http://support.microsoft.com/?id=211533
    Q291293 — XL2002: Color Palette Looks Different in Microsoft Excel 2002
    http://support.microsoft.com/?id=291293

    Q163230 — Thick Borders May Not Be Printed in Low Printer Resolution (163230) — When you print thick borders in Microsoft Excel, the borders may be partially printed, or the borders may not be printed at all.

    Q320531 — OFF: Changes to Fill Color and Fill Pattern Are Not Displayed,
    Incorrect/missing colors may occur with use of High Contrast under Display tab of Accessibility Options. Colors don’t show on monitor however, you may be able to see the changes in print preview and on a printed page. Also see Problems topic.

    MS KB Term Article title — http://support.microsoft.com/kb/ [ref] Product
    Q211661 XL2000: Black and White Printer Prints Colored Lines As Grayscale Excel 2000
    Q248175 XL2000: Border Color of Lines Returns Incorrect RGB Value When Border Color Is Set to Automatic VBA
    Q176839 XL: Buttons on Toolbar Created in Earlier Version May Lose Color Excel
    Q211650 XL2000: Cannot Change Fill Color for Walls or Floor on 3-D Chart Excel 2000
    Q214312 XL2000: Cannot Change Series Colors on a Surface Chart Excel 2000
    Q95478 XL: Can’t Print Color Headers and Footers Excel
    Q212746 XL: Cell Fill Color Bleeds into Adjacent Cells When Viewed in Web Browser Excel
    Q82015 XL: Changing Series Colors on a Surface Chart Excel
    Q211533 XL2000: Color Palette Looks Different in Microsoft Excel 2000 VBA
    Q229006 XL: Colors in HTML File Don’t Appear as Expected When Opening Page in Excel Excel
    Q134261 XL: Data Map Colors Lost When File Exported to Macintosh Excel
    Q211828 XL2000: Fill Colors May Be Saved Incorrectly with WK3 File Excel 2000
    Q214097 XL2000: Header or Footer Is Not Printed in Color Excel 2000
    Q202355 XL2000: Hyperlink Colors Don’t Show Expected Color Format Excel 2000
    Q213191 XL2000: Modules Cannot Be Printed in Color Excel 2000
    Q173083 XL: Modules Cannot Be Printed in Color VBA
    Q213201 XL2000: RGB Function May Map to Unexpected Color VBA
    Q213801 XL: Sample Visual Basic Code to Create Color Index Table Excel
    Q214353 XL2000: Toolbar Buttons Created in Earlier Version May Lose Color Excel 2000
    Q211728 XL2000: Trendline Equation Label Does Not Use the Specified Color Excel 2000
    Q211677 XL2000: Unexpected Font or Color Formatting Applied to Chart Excel 2000
    Q213688 XL2000: Using ColorIndex Property to Set Color of Borders Results in Unexpected Behavior VBA

    Microsoft MSDN (#msdn)

    ColorIndex Property, article within Office Web Components in MSDN (shows the color palette).

    Please send your comments concerning this web page to: David McRitchie send email comments

    Copyright © 1997 — 2011 , F. David McRitchie, All Rights Reserved

    Источник

    Adblock
    detector

    Содержание

    • Список кодов индекса цвета 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Конец подписки

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

    Skip to content

    Excel VBA ColorIndex

    • VBA ColorIndex

    VBA ColorIndex Property of Excel VBA is very useful to set the fill colors, border colors and font colors. Excel VBA ColorIndex returns index values from 1 to 56, -4105 and -4142. You can set the default colors using VBA enumeration number -4105 ( or xlColorIndexAutomatic). We can set VBA colorIndex -4142 (or xlColorIndexNone) enumeration to clear the colors or set to no colors.

    Excel VBA ColorIndex

    Syntax of Excel VBA ColorIndex

    Here is the syntax of ColorIndex property of Excel VBA. You can set or return the color index value of the Excel Objects using the following VBA colorindex syntax.

    expression.ColorIndex

    Excel VBA Syntax to get the ColorIndex Value of the Excel Font, Interior or Border Color and store it in a Variable:

    dblColorValue= expression.ColorIndex

    Syntax to set the ColorIndex Value in Excel VBA to Excel Color Objects using Excel ColorIndex value:

    expression.ColorIndex= IndexValue (1 to 56,-4105 or -4142)

    ColorIndex in Excel VBA

    Here are the list of Excel VBA ColorIndex Values and respective Colors:

    ColorIndex Excel VBA Color ColorIndex Excel VBA Color
    1 RGB(0,0,0) 29 RGB(128,0,128)
    2 RGB(255,255,255) 30 RGB(128,0,0)
    3 RGB(255,0,0) 31 RGB(0,128,128)
    4 RGB(0,255,0) 32 RGB(0,0,255)
    5 RGB(0,0,255) 33 RGB(0,204,255)
    6 RGB(255,255,0) 34 RGB(204,255,255)
    7 RGB(255,0,255) 35 RGB(204,255,204)
    8 RGB(0,255,255) 36 RGB(255,255,153)
    9 RGB(128,0,0) 37 RGB(153,204,255)
    10 RGB(0,128,0) 38 RGB(255,153,204)
    11 RGB(0,0,128) 39 RGB(204,153,255)
    12 RGB(128,128,0) 40 RGB(255,204,153)
    13 RGB(128,0,128) 41 RGB(51,102,255)
    14 RGB(0,128,128) 42 RGB(51,204,204)
    15 RGB(192,192,192) 43 RGB(153,204,0)
    16 RGB(128,128,128) 44 RGB(255,204,0)
    17 RGB(153,153,255) 45 RGB(255,153,0)
    18 RGB(153,51,102) 46 RGB(255,102,0)
    19 RGB(255,255,204) 47 RGB(102,102,153)
    20 RGB(204,255,255) 48 RGB(150,150,150)
    21 RGB(102,0,102) 49 RGB(0,51,102)
    22 RGB(255,128,128) 50 RGB(51,153,102)
    23 RGB(0,102,204) 51 RGB(0,51,0)
    24 RGB(204,204,255) 52 RGB(51,51,0)
    25 RGB(0,0,128) 53 RGB(153,51,0)
    26 RGB(255,0,255) 54 RGB(153,51,102)
    27 RGB(255,255,0) 55 RGB(51,51,153)
    28 RGB(0,255,255) 56 RGB(51,51,51)

    VBA to Print ColorIndex Table

    Here is the Excel VBA Macro to print Excel ColorIndex Values and respective colors in Excel Sheet.
    VBA to Print ColorIndex in Excel Range

    Sub sbExcel_VBA_PrintColorIndex()
    rowCntr = 2
    colCntr = 2
    
    For iCntr = 1 To 56
    
    Cells(rowCntr, colCntr).Interior.ColorIndex = iCntr
    Cells(rowCntr, colCntr) = iCntr
    If iCntr > 1 And iCntr Mod 14 = 0 Then
        colCntr = colCntr + 1
        rowCntr = 2
    Else
    rowCntr = rowCntr + 1
    End If
    
    Next
    
    
    End Sub
    

    Set ColorIndex in Excel VBA

    Here are the list of Excel VBA code to set ColorIndex to a Range of cells in Microsoft Excel Sheet.

    Font Colors in Excel VBA

    We can set the font colors in Excel VBA using ColorIndex property of Font Object. Here is the simple excel vba font color macro to set the font color of a given range A1:E20.

    Sub SetFontColorIndex_Range()
        Range("A1:E20").Font.ColorIndex = 40
    End Sub
    

    You can also get the fornt colors using ColorIndex and store it in a variable. Please check the below code snippet:

    myVar=Range("A1").Font.ColorIndex
    

    This will return the font color and assign to a variable.

    Interior Colors in Excel VBA

    We can change the Interior or fill colors of a range using Excel VBA ColorIndex Property. Excel Interior Color macro heps you to change the interior color of an obect.

    Sub SetInteriorColorIndex_Range()
        Range("A1:E20").Interior.ColorIndex = 41
    End Sub
    

    You can get Cell colors using Excel VBA, here is the get cell color excel vba macro to get the cell background colors.

    myVar=Range("A1:E20").Interior.ColorIndex
    

    Border Colors in Excel VBA

    ColorIndex property of Borders is very easy to set the border colors in Excel VBA. Here is

    Sub SetBordersColorIndex_Range()
    Range("A1:E20").Borders.ColorIndex = 42
    End Sub
    

    Clear Colors in Excel VBA

    Some times we need to fill no colors in Excel, we can clear the Excel Object colors such as font, border and fill colors and set to automatic or no fill color. Here are example macro to clear the color and fill no colors.

    Clear Background Color in Excel VBA

    We often required to clear the background or fill color of the excel object. We can use the following Excel Macro to clear the background colors and set no interior colors.

    Sub SetClearBackgroundColor_ColorIndex_Range()
        Range("A1:E20").Interior.ColorIndex = -4142
    End Sub
    

    The above macro will set the Interior.ColorIndex to -4142 enumeration. Interior.ColorIndex = -4142 is enumeration to clear the background or fill color.

    Similarly, we can clear the boder colors using Excel VBA as shown below:

    Sub SetClearBorders_ColorIndex_Range()
        Range("A1:E20").Borders.ColorIndex = -4142
    End Sub
    

    We can set the font colors to default or automatic colors using Excel VBA ColorIndex property of Font object. Here is an example:

    Sub SetClearFontColorIndex_Range()
        Range("A1:E20").Font.ColorIndex = -4105
    End Sub
    

    VBA Colors

    We can set the colors in VBA using many approaches. We use ColorIndex Property, VBA Color Constants or set RGB Colors. We have already seen how to use ColorIndex in Excel VBA. Let us see the Excel VBA Color Constants and RGB Colors.

    Excel VBA Color Constants

    We can use the VBA Color Constants to set the colors of Excel Objects. Here is an easy to understand example:

    Sub sbExcel_VBA_ColorConstants()
    Cells(2, 4).Interior.Color = vbBlack
    Cells(3, 4).Interior.Color = vbRed
    Cells(4, 4).Interior.Color = vbGreen
    Cells(5, 4).Interior.Color = vbYellow
    Cells(6, 4).Interior.Color = vbBlue
    Cells(7, 4).Interior.Color = vbMagenta
    Cells(8, 4).Interior.Color = vbCyan
    Cells(9, 4).Interior.Color = vbWhite
    
    End Sub
    
    VBA Color Constant VALUE Excel VBA Color & RGB
    vbBlack 0x0 RGB(0,0,0)
    vbRed 0xFF RGB(255,0,0)
    vbGreen 0xFF00 RGB(0,255,0)
    vbYellow 0xFFFF RGB(255,255,0)
    vbBlue 0xFF0000 RGB(0,0,255)
    vbMagenta 0xFF00FF RGB(255,0,255)
    vbCyan 0xFFFF00 RGB(0,255,255)
    vbWhite 0xFFFFFF RGB(255,255,255)

    RGB Colors in Excel VBA

    We have only few color codes when we use Constants or ColorIndex Property. RGB helps us to use all possible combination of colors with Red, Green and Blue. Here is a simple Excel macro to explain the RGB in VBA.

    Sub ChangeBackgourdColorRGB_Range()
        Range("A1:E20").Interior.Color = rgb(125, 205, 99)
    End Sub
    

    RGB color can be any number between 0 and 255. Here are the list of RGB colors for Excel VBA ColorIndex color codes:
    Excel VBA ColorIndex with RGB

    Effortlessly Manage Your Projects and Resources
    120+ Professional Project Management Templates!

    A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

    Save Up to 85% LIMITED TIME OFFER
    Excel VBA Project Management Templates
    All-in-One Pack
    120+ Project Management Templates
    Essential Pack
    50+ Project Management Templates

    Excel Pack
    50+ Excel PM Templates

    PowerPoint Pack
    50+ Excel PM Templates

    MS Word Pack
    25+ Word PM Templates

    Ultimate Project Management Template

    Ultimate Resource Management Template

    Project Portfolio Management Templates

    Related Posts

    • Syntax of Excel VBA ColorIndex
    • ColorIndex in Excel VBA
      • VBA to Print ColorIndex Table
    • Set ColorIndex in Excel VBA
      • Font Colors in Excel VBA
      • Interior Colors in Excel VBA
      • Border Colors in Excel VBA
    • Clear Colors in Excel VBA
      • Clear Background Color in Excel VBA
    • VBA Colors
      • Excel VBA Color Constants
      • RGB Colors in Excel VBA

    VBA Reference

    Effortlessly
    Manage Your Projects

    120+ Project Management Templates

    Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

    120+ PM Templates Includes:

    Effectively Manage Your
    Projects and  Resources

    With Our Professional and Premium Project Management Templates!

    ANALYSISTABS.COM provides free and premium project management tools, templates and dashboards for effectively managing the projects and analyzing the data.

    We’re a crew of professionals expertise in Excel VBA, Business Analysis, Project Management. We’re Sharing our map to Project success with innovative tools, templates, tutorials and tips.

    Project Management
    Excel VBA

    Download Free Excel 2007, 2010, 2013 Add-in for Creating Innovative Dashboards, Tools for Data Mining, Analysis, Visualization. Learn VBA for MS Excel, Word, PowerPoint, Access, Outlook to develop applications for retail, insurance, banking, finance, telecom, healthcare domains.

    Analysistabs Logo

    Page load link

    Go to Top

    In this Article

    • VBA Color Index Codes List
      • VBA ColorIndex Examples
    • VBA Color Property
    • VB Color
    • RGB Colors
    • ColorIndex Codes List & RGB Colors in Access VBA

    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

    excel color references


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

    Sub ColorRef()
    
    Dim x As Integer
    
    For x = 1 To 56
      If x < Then
        Cells(x, 1).Interior.ColorIndex = x
        Cells(x, 2) = x
      Else
        Cells(x - 28, 3).Interior.ColorIndex = x
        Cells(x - 28, 4) = x
      End If
    Next x
    
    End Sub
    

    VBA ColorIndex Examples

    Set Cell Background Color

    This example sets the cell’s background color.

    Range("A1").Interior.ColorIndex = 6

    Set Cell Font Color

    This example sets the cell’s font color.

    Range("A1").Font.ColorIndex = 5

    Set Cell Borders Color

    This example sets the cell’s border color.

    Range("A1").Borders.ColorIndex = 5

    Get Cell Background ColorIndex

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

    Dim col as Integer
    
    col = Range("A1").Interior.ColorIndex

    Set a Cell Background Color to Another Cell’s Color

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

    Range("A1").Interior.ColorIndex  = Range("B1").Interior.ColorIndex

    VBA Color Property

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

    1. vbColor
    2. RGB Colors

    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:
    vba vbcolor
    However, as you can see from the table, your options are extremely limited.

    Set Cell Background Color

    Range("A1").Interior.Color = vbYellow

    Set Cell Font Color

    Range("A1").Font.Color = vbBlue

    Set Cell Borders Color

    Range("A1").Borders.Color = vbRed

    Set a Cell Background Color to Another Cell’s Color

    Range("A1").Interior.Color  = Range("B1").Interior.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:

    Range("A1").Interior.Color = RGB(255,255,0)

    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:

    Range("A1").Interior.Color = RGB(128,0,128)

    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.

    Private Sub cmdSave_Click()
    'change the background color of the save button when the record is saved.
       DoCmd.RunCommand acCmdSaveRecord
       cmdSave.BackColor = vbGreen
    End Sub

    vba color change 1

    title keywords f1_keywords ms.prod api_name ms.assetid ms.date ms.localizationpriority

    ColorIndex property (Excel Graph)

    vbagr10.chm5207225

    vbagr10.chm5207225

    excel

    Excel.ColorIndex

    e9a9c9de-8a42-0f61-be25-4c158709df68

    04/10/2019

    high

    ColorIndex property (Excel Graph)

    Returns or sets the color of the border, font, or interior, as shown in the following table. The color is specified as an index value into the current color palette, or as one of the following XlColorIndex constants: xlColorIndexAutomatic or xlColorIndexNone. Read/write Variant.

    Syntax

    expression.ColorIndex

    expression Required. An expression that returns one of the objects in the Applies To list.

    Remarks

    Object Description
    Border The color of the border.
    Font The color of the font.
    Interior The color of the interior fill. Set ColorIndex to xlColorIndexNone to specify that you don’t want an interior fill. Set ColorIndex to xlColorIndexAutomatic to specify the automatic fill (for drawing objects).

    This property specifies a color as an index into the color palette. The following illustration shows the color-index values in the default color palette.

    Color

    Example

    The following examples assume that you are using the default color palette.

    This example sets the color of the major gridlines for the value axis.

    With myChart.Axes(xlValue) 
     If .HasMajorGridlines Then 
     'Set color to blue 
     .MajorGridlines.Border.ColorIndex = 5 
     End If 
    End With

    This example sets the color of the chart area interior to red, and sets the border color to blue.

    With myChart.ChartArea 
     .Interior.ColorIndex = 3 
     .Border.ColorIndex = 5 
    End With

    [!NOTE]
    If you would like to use color with FormatCondition in Visual Basic, see the Interior.ColorIndex property.

    [!includeSupport and feedback]

    Понравилась статья? Поделить с друзьями:
  • Excel color index color
  • Excel color if not in list
  • Excel color fill in the
  • Excel color column if
  • Excel color cell from value