What is font color in excel

Содержание

  1. Format text in cells
  2. Change font style, size, color, or apply effects
  3. Change the text alignment
  4. Clear formatting
  5. Change font style, size, color, or apply effects
  6. Change the text alignment
  7. Clear formatting
  8. Свойство Font.Color (Excel)
  9. Синтаксис
  10. Примечания
  11. Пример
  12. Поддержка и обратная связь
  13. Change the color of text
  14. Change the text color for a cell or range of cells
  15. Apply a custom color
  16. Format the color of a worksheet tab
  17. What is font color in excel
  18. Question
  19. Answers
  20. Excel Format Fonts
  21. Format Fonts
  22. Font Color
  23. Font Name
  24. Font Size
  25. Font Characteristics
  26. Chapter Summary

Format text in cells

Formatting text or numbers can make them appear more visible especially when you have a large worksheet. Changing default formats includes things like changing the font color, style, size, text alignment in a cell, or apply formatting effects. This article shows you how you can apply different formats and also undo them.

If you want text or numbers in a cell to appear bold, italic, or have a single or double underline, select the cell and on the Home tab, pick the format you want:

Change font style, size, color, or apply effects

For a different font style, click the arrow next to the default font Calibri and pick the style you want.

To increase or decrease the font size, click the arrow next to the default size 11 and pick another text size.

To change the font color, click Font Color and pick a color.

To add a background color, click Fill Color next to Font Color .

To apply strikethrough, superscript, or subscript formatting, click the Dialog Box Launcher, and select an option under Effects.

Change the text alignment

You can position the text within a cell so that it is centered, aligned left or right. If it’s a long line of text, you can apply Wrap Text so that all the text is visible.

Select the text that you want to align, and on the Home tab, pick the alignment option you want.

Clear formatting

If you change your mind after applying any formatting, to undo it, select the text, and on the Home tab, click Clear > Clear Formats.

Change font style, size, color, or apply effects

For a different font style, click the arrow next to the default font Calibri and pick the style you want.

To increase or decrease the font size, click the arrow next to the default size 11 and pick another text size.

To change the font color, click Font Color and pick a color.

To add a background color, click Fill Color next to Font Color .

For boldface, italics, underline, double underline, and strikethrough, select the appropriate option under Font.

Change the text alignment

You can position the text within a cell so that it is centered, aligned left or right. If it’s a long line of text, you can apply Wrap Text so that all the text is visible.

Select the text that you want to align, and on the Home tab, pick the alignment option you want.

Clear formatting

If you change your mind after applying any formatting, to undo it, select the text, and on the Home tab, click Clear > Clear Formats.

Источник

Свойство Font.Color (Excel)

Возвращает или задает основной цвет объекта, как показано в таблице в разделе примечаний. Используйте функцию RGB для создания значения цвета. Для чтения и записи, Variant.

Синтаксис

expression. Цвет

Выражение Выражение, возвращающее объект Font .

Примечания

Object Цвет
Border Цвет границы.
Borders Цвет всех четырех границ диапазона. Если они не совпадают по цвету, функция Color возвращает значение 0 (ноль).
Font Цвет шрифта.
Interior Цвет заливки ячейки или цвет заливки объекта рисунка.
Вкладка Цвет вкладки.

Пример

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

Поддержка и обратная связь

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

Источник

Change the color of text

You can make the data on your worksheets more visible by changing the font color of cells or a range of cells, formatting the color of worksheet tabs, or changing the color of formulas.

For information on changing the background color of cells, or applying patterns or fill colors, see Add or change the background color of cells.

Change the text color for a cell or range of cells

Select the cell or range of cells that has the data you want to format. You can also select just a portion of the text within a cell.

On the Home tab, choose the arrow next to Font Color .

Under Theme Colors or Standard Colors, choose a color.

Tip: To apply the most recently selected text color, on the Home tab, choose Font Color.

Apply a custom color

If you want a specific font color, here’s how you can blend your custom color:

Click Home > Font Color arrow > More Colors.

On the Custom tab, in the Colors box, select the color you want.

If you know the color numbers of a specific color, pick RGB (Red, Green, Blue) or HSL (Hue, Sat, Lum) in the Color model box, and then enter the numbers to match the exact color shade you want.

Tip: To quickly copy a font color you used to other cells, select a cell with that font color, and double-click Format Painter . Then click the cells you want to format. When you’re done, click Format Painter again to turn it off.

Format the color of a worksheet tab

Right-click the worksheet tab whose color you want to change.

Choose Tab Color, and then select the color you want.

The color of the tab changes, but not the color of the font. When you choose a dark tab color, the font switches to white, and when you choose a light color for the tab, the font switches to black.

Источник

What is font color in excel

Question

First off, 18.8.22 font (Font) I think has a type/bad subclause. For the child element color it has «color (Data Bar Color)» which reference specifying a color in a chart.

Now on to my question — if a cell’s style is applying a font and the color is not set in the font, then what color is the font? I think it’s auto, but I’m not sure.

I say this because TextColorAutoOnVariousBackgrounds.xlsx has the cells set to auto, and I don’t see that explicitly set anywhere in the XLSX file.

Also, why does auto text stay black on a black background?

Answers

Thank you for raising your questions regarding the default font color in Excel, and the issue why Text with the font color defined as Autocolor in a cell with a black background color has a black font color.

To answer your first question. A cell with a font definition without a color defined will default to Auto. In Excel, that means the font color will be black.

To answer your second question, the reason that the cell text remains black when a black background is applied is due to the implement of autocolor in Excel, which uses an OS defined system color which is commonly black.

Sincerely,
Will Gregg | open specifications

Источник

Excel Format Fonts

Format Fonts

You can format fonts in four different ways: color, font name, size and other characteristics.

Font Color

The default color for fonts is black.

Colors are applied to fonts by using the «Font color» function.

How to apply colors to fonts

  1. Select cell
  2. Select font color
  3. Type text

The font color goes for both numbers and text.

The Font color command remembers the color used last time.

Note: Custom colors are applied in the same way for both cells and fonts. You can read more about it in the Apply colors to cells chapter.

Lets try an example, step by step:

  1. Select standard font color Red
  2. Type A1(Hello)
  3. Hit enter
  4. Select standard font color Green
  5. Type B1(World!)
  6. Hit enter

Font Name

The default font in Excel is Calibri.

The font name can be changed for both numbers and text.

Why change the font name in Excel?

  • Make the data easier to read
  • Make the presentation more appealing

How to change the font name:

  1. Select a range
  2. Click the font name drop down menu
  3. Select a font

Let’s have a look at an example.

  1. Select A1:C4
  2. Click the font name drop down menu
  3. Select Arial

The example has both text ( A1:B1 ) and numbers ( A4:C4 )

Good job! You have successfully changed the fonts from Calibri to Arial for the range A1:C4 .

Font Size

To change the font size of the font, just click on the font size drop down menu:

Font Characteristics

You can apply different characteristics to fonts such as:

  • Bold
  • Italic
  • Underlined
  • Strike though

The commands can be found below the font name drop down menu:

Bold is applied by either clicking the Bold (B) icon in the Ribbon or using the keyboard shortcut CTRL + B or Command + B

Italic is applied by either clicking the Italic (I) icon or using the keyboard shortcut CTRL + I or Command + I

Underline is applied by either clicking the Underline (U) icon or using the keyboard shortcut CTRL + U or Command + U

Strikethrough is applied by either clicking the Strikethrough (ab) icon or using the keyboard shortcut CTRL + 5 or Command + Shift + X

Chapter Summary

Fonts can be changed in four different ways: color, font name, size and other characteristics. The fonts are changed to make the spreadsheet more readable and delicate.

Источник

Изменение цвета текста (шрифта) в ячейке рабочего листа Excel с помощью кода VBA. Свойства ячейки (диапазона) .Font.Color, .Font.ColorIndex и .Font.TintAndShade.

Использование цветовой палитры для присвоения цвета тексту в ячейке листа Excel аналогично присвоению цвета фону ячейки, только свойство диапазона .Interior меняем на свойство .Font.

Цвет текста и предопределенные константы

Цвет шрифту в ячейке можно присвоить с помощью предопределенных констант:

Range(«A1:C3»).Font.Color = vbGreen

Range(Cells(4, 1), Cells(6, 3)).Font.Color = vbBlue

Cells(7, 1).Font.Color = vbRed

Напомню, что вместо индексов строк и столбцов можно использовать переменные. Список предопределенных констант смотрите здесь.

Цвет шрифта и модель RGB

Для изменения цвета текста в ячейке можно использовать цветовую модель RGB:

Range(«A1»).Font.Color = RGB(200, 150, 250)

Cells(2, 1).Font.Color = RGB(200, 150, 100)

Аргументы функции RGB могут принимать значения от 0 до 255. Если все аргументы равны 0, цвет — черный, если все аргументы равны 255, цвет — белый. Функция RGB преобразует числовые значения основных цветов (красного, зеленого и синего) в индекс основной палитры.

Список стандартных цветов с RGB-кодами смотрите в статье: HTML. Коды и названия цветов.

Свойство .Font.ColorIndex

Свойство .Font.ColorIndex может принимать значения от 1 до 56. Это стандартная ограниченная палитра, которая существовала до Excel 2007 и используется до сих пор. Посмотрите примеры:

Range(«A1:D6»).Font.ColorIndex = 5

Cells(1, 6).Font.ColorIndex = 12

Таблица соответствия значений ограниченной палитры цвету:

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

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

Подробнее о стандартной палитре Excel смотрите в статье: Стандартная палитра из 56 цветов.

Свойство .Font.ThemeColor

Свойство .Font.ThemeColor может принимать числовые или текстовые значения констант из коллекции MsoThemeColorIndex:

Range(«A1»).Font.ThemeColor = msoThemeColorHyperlink

Cells(2, 1).Font.ThemeColor = msoThemeColorAccent4

Основная палитра

Основная палитра, начиная c Excel 2007, состоит из 16777216 цветов. Свойство .Font.Color может принимать значения от 0 до 16777215, причем 0 соответствует черному цвету, а 16777215 — белому.

Cells(1, 1).Font.Color = 0

Cells(2, 1).Font.Color = 6777215

Cells(3, 1).Font.Color = 4569325

Отрицательные значения свойства .Font.Color

При записи в Excel макрорекордером макроса с присвоением шрифту цвета используются отрицательные значения свойства .Font.Color, которые могут быть в пределах от -16777215 до -1. Отрицательные значения соответствуют по цвету положительному значению, равному сумме наибольшего индекса основной палитры и данного отрицательного значения. Например, отрицательное значение -8257985 соответствует положительному значению 8519230, являющегося результатом выражения 16777215 + (-8257985). Цвета текста двух ячеек из следующего кода будут одинаковы:

Cells(1, 1).Font.Color = 8257985

Cells(2, 1).Font.Color = 8519230

Свойство .Font.TintAndShade

Еще при записи макроса с присвоением шрифту цвета макрорекордером добавляется свойство .Font.TintAndShade, которое осветляет или затемняет цвет и принимает следующие значения:

  • -1 — затемненный;
  • 0 — нейтральный;
  • 1 — осветленный.

При тестировании этого свойства в Excel 2016, сравнивая затемненные и осветленные цвета, разницы не заметил. Сравните сами:

Sub Test()

With Range(Cells(1, 1), Cells(3, 1))

   .Value = «Сравниваем оттенки»

   .Font.Color = 37985

End With

Cells(1, 1).Font.TintAndShade = 1

Cells(2, 1).Font.TintAndShade = 0

Cells(3, 1).Font.TintAndShade = 1

End Sub

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

Разноцветный текст в ячейке

Отдельным частям текста в ячейке можно присвоить разные цвета. Для этого используется свойство Range.Characters:

Sub Test()

    With Range(«A1»)

        .Font.Color = vbBlack

        .Value = «Океан — Солнце — Оазис»

        .Font.Size = 30

        .Characters(1, 5).Font.Color = vbBlue

        .Characters(9, 6).Font.Color = RGB(255, 230, 0)

        .Characters(18, 5).Font.Color = RGB(119, 221, 119)

    End With

End Sub

Результат работы кода:

Разноцветный текст в ячейке


Color is sometimes used to convey meaning beyond the basic text. In a course syllabus, for example, you may use color to emphasize an important statement. Or, on a PowerPoint slide showing a multiple choice question, you might show the correct answer in green and color the incorrect answers in red.

Contents

  • 1 What is font color?
  • 2 What is font color in MS Word?
  • 3 Where is the font color?
  • 4 Why is font colour important?
  • 5 What is text Colour in HTML?
  • 6 What is font color in Excel?
  • 7 What is font in MS Word?
  • 8 What is a font style?
  • 9 How do you color in Word?
  • 10 What is the code for colors?
  • 11 What does yellow font mean?
  • 12 What is background Colour and text Colour?
  • 13 How do I use font color in HTML?
  • 14 How do you color text in HTML?
  • 15 What is font style in HTML?
  • 16 What is a font in Excel?
  • 17 How do I identify a font in Excel?
  • 18 How do I color one text in Excel?
  • 19 What is an example of a font?
  • 20 How many fonts are there?

What is font color?

{{ Font color }} is how you insert colorized text, such as red, orange, green, blue and indigo, and many others. You can specify its background color at the same time. {{ Font color }} is also how you can color wikilinks to something other than blue for when you need to work within background colors.

What is font color in MS Word?

The Font Color button shows which color it assigns to text. To change the color, click the menu triangle to the button’s left and choose a color from the menu displayed. To restore the font color, choose Automatic from the Font Color menu. The Automatic color is set by the text style.

Where is the font color?

On the Home tab, in the Font group, choose the arrow next to Font Color, and then select a color. You can also use the formatting options on the Mini toolbar to quickly format text.

Why is font colour important?

Just like fonts help add to the imagery of your text content, colour has a big impact on the psychology of your written word as well. Colour helps call attention to your text, but you may not realize that colours also evoke emotions. Here are the different feelings that colours can make your audience feel.

What is text Colour in HTML?

The HTML color Attribute is used to specify the text color inside the element. Syntax: Attention reader!

What is font color in Excel?

Right-click the worksheet tab whose color you want to change. Choose Tab Color, and then select the color you want. The color of the tab changes, but not the color of the font. When you choose a dark tab color, the font switches to white, and when you choose a light color for the tab, the font switches to black.

What is font in MS Word?

A font is a graphical representation of text that may include a different typeface, point size, weight, color, or design.Software programs like Microsoft Word, Microsoft Excel, and WordPad allow users to change the font when typing text in the document or spreadsheet, as do web designers.

What is a font style?

In a web browser, font style is a CSS (custom style sheet) property used in HTML and ASP.NET programming, defining the font style for text. There are four possible options for font style. normal. italic.

How do you color in Word?

Go to Design > Page Color. Choose the color you want. If you don’t see the color you want, select More Colors and then pick a color from any of the options in the Color box.

What is the code for colors?

Major hexadecimal color codes

Color Name Color Code
Red #FF0000
Cyan #00FFFF
Blue #0000FF
DarkBlue #00008B

What does yellow font mean?

Yellow: Yellow is frequently used to grab your attention. It stands out, is bold, and is frequently used. However, being so bold, people can find it repulsive and even ignore it. Common yellow brands include McDonalds and Subway.

What is background Colour and text Colour?

The background-color property sets the background color of an element. The background of an element is the total size of the element, including padding and border (but not the margin). Tip: Use a background color and a text color that makes the text easy to read. Default value: transparent.

How do I use font color in HTML?

To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML

tag, with the CSS property color. HTML5 do not support the tag, so the CSS style is used to add font color.

How do you color text in HTML?

The most common way of coloring HTML text is by using hexadecimal color codes (Hex code for short). Simply add a style attribute to the text element you want to color – a paragraph in the example below – and use the color property with your Hex code.

What is font style in HTML?

Some Font Examples

Generic Font Family Examples of Font Names
Sans-serif Arial Verdana Helvetica
Monospace Courier New Lucida Console Monaco
Cursive Brush Script MT Lucida Handwriting
Fantasy Copperplate Papyrus

What is a font in Excel?

Fonts in Excel
The font is the style and/or size of your text and characters. Changing the font of your numbers and text in an Excel worksheet can help your document to look more appealing and, at times, make it easier for the reader to digest the information.

How do I identify a font in Excel?

Changing font type, size, and color

  1. Select a cell or range of cells.
  2. Click the down arrow to the right of the Font Name list box on the Formatting toolbar.
  3. A drop-down list of available fonts appears.
  4. Click the typeface of your choice.
  5. The selection list closes, and the new font is applied to the selected cells.

How do I color one text in Excel?

Apply conditional formatting based on text in a cell

  1. Select the cells you want to apply conditional formatting to. Click the first cell in the range, and then drag to the last cell.
  2. Click HOME > Conditional Formatting > Highlight Cells Rules > Text that Contains.
  3. Select the color format for the text, and click OK.

What is an example of a font?

For example Garamond, Times, and Arial are typefaces. Whereas font is a specific style of typeface with a set width, size, and weight. For example, Arial is a typeface; 16pt Arial Bold is a font. So typeface is the creative part and font is the structure.

How many fonts are there?

What Font Is, a free font finder uses a catalogue of 550,000+ fonts which leads me to believe there are at least half a million fonts in existance. A quick search in MyFonts, the largest distributor of commercial fonts, shows them housing over 130,000 fonts which fall into: Font familes: 36,000+


Format Fonts

You can format fonts in four different ways: color, font name, size and other characteristics.


Font Color

The default color for fonts is black.

Colors are applied to fonts by using the «Font color» function.

How to apply colors to fonts

  1. Select cell
  2. Select font color
  3. Type text

The font color goes for both numbers and text.

The Font color command remembers the color used last time.

Note: Custom colors are applied in the same way for both cells and fonts. You can read more about it in the Apply colors to cells chapter.

Lets try an example, step by step:

  1. Select standard font color Red
  2. Type A1(Hello)
  3. Hit enter
  4. Select standard font color Green
  5. Type B1(World!)
  6. Hit enter



Font Name

The default font in Excel is Calibri.

The font name can be changed for both numbers and text.

Why change the font name in Excel?

  • Make the data easier to read
  • Make the presentation more appealing

How to change the font name:

  1. Select a range
  2. Click the font name drop down menu
  3. Select a font

Let’s have a look at an example.

  1. Select A1:C4
  2. Click the font name drop down menu
  3. Select Arial

The example has both text (A1:B1) and numbers (A4:C4)

Good job! You have successfully changed the fonts from Calibri to Arial for the range A1:C4.


Font Size

To change the font size of the font, just click on the font size drop down menu:


Font Characteristics

You can apply different characteristics to fonts such as:

  • Bold
  • Italic
  • Underlined
  • Strike though

The commands can be found below the font name drop down menu:

Bold is applied by either clicking the Bold (B) icon in the Ribbon or using the keyboard shortcut CTRL + B or Command + B

Italic is applied by either clicking the Italic (I) icon or using the keyboard shortcut CTRL + I or Command + I

Underline is applied by either clicking the Underline (U) icon or using the keyboard shortcut CTRL + U or Command + U

Strikethrough is applied by either clicking the Strikethrough (ab) icon or using the keyboard shortcut CTRL + 5 or Command + Shift + X


Chapter Summary

Fonts can be changed in four different ways: color, font name, size and other characteristics. The fonts are changed to make the spreadsheet more readable and delicate.


  • Remove From My Forums
  • Question

  • Hi all;

    First off, 18.8.22 font (Font) I think has a type/bad subclause. For the child element color it has «color (Data Bar Color)» which reference specifying a color in a chart.

    Now on to my question — if a cell’s style is applying a font and the color is not set in the font, then what color is the font? I think it’s auto, but I’m not sure.

    I say this because TextColorAutoOnVariousBackgrounds.xlsx has the cells set to auto, and I don’t see that explicitly set anywhere in the XLSX file.

    Also, why does auto text stay black on a black background?

    thanks — dave

    ATE-349


    What we did for the last 6 months —
    Made the world’s coolest reporting & docgen system even more amazing

    • Edited by

      Thursday, December 28, 2017 10:56 PM

Answers

  • Hi Dave,

    Thank you for raising your questions regarding the default font color in Excel, and the issue why Text with the font color defined as Autocolor in a cell with a black background color has a black font color.

    To answer your first question. A cell with a font definition without a color defined will default to Auto. In Excel, that means the font color will be black.

    To answer your second question, the reason that the cell text remains black when a black background is applied is due to the implement of autocolor in Excel, which uses an OS defined system color which is commonly black. 

    Sincerely,
    Will Gregg | open specifications

    • Marked as answer by
      DavidThielen
      Thursday, January 4, 2018 2:44 AM

Written by Puneet for Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel for Mac

Key Notes

  • To make changes in a font, you need to use the VBA Font object.
  • There is a total of 18 properties with the font object that you can access and make changes.

VBA Font Object

In VBA, there is a font object which you can use to change properties of the font from a cell, like, font color, font size, font type, and you can also apply bold and italic to the font.

Syntax

expression.font

To use it, first, you need to define the cell address, which you can specify in the following ways.

Selection.Font
Range("A1").Font
Cells(1, 1).Font
Range("A1:A5").Font

To change the color of the font, you have two different ways:

1. Using Color Constants

Excel has a few color constants that you can use to apply color to the font. For example, if you want to apply the red color to the font in cell A1, the code would be like the below:

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

In the above code, after the font object, color is the property and you have used the vbRed constant that tells VBA to apply the red color to the cell A1. There is a total of eight constants that you can use:

  1. vbBlack: Black
  2. vbRed: Red
  3. vbGreen: Green
  4. vbYellow: Yellow
  5. vbBlue: Blue
  6. vbMagenta: Magenta
  7. vbCyan: Cyan
  8. vbWhite: White

2. Using RGB

You can also use the RGB color code to apply color to the font. RGB is the combination of red, green, and blue colors, where you can create a custom color using the code. Let’s say if you want to apply a combination of green and blue color to cell A1 the code would be:

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

VBA Font Size

Font object also gives you access to the size property of the font. Let’s say you want to apply the font size of 16 to the font in the cell A1, the code would be:

Range("A1").Font.Size = 16

If you want to apply font size to all cells in a worksheet you can use the following code:

Cells.Font.Size = 16

And if only want to apply font size to cells where you have data, the code would be:

ActiveSheet.UsedRange.Font.Size = 16

Or to the selected cell.

Selection.Font.Size = 16

VBA Font Name

In the same way, you can also change the font name using the name property of the font object. Let’s say you want to apply the “Consolas” font the cell A1. The code would be:

Range("A1").Font.Name = "Consolas"

While using this property, you need to type the correct name of the font that you want to apply, and if somehow the name is incorrect, it won’t show you an error.

VBA Font Bold, Italic, and Underline

There are also properties that you can use to make the font bold, italic, and underline. Below are the codes that you need to write for this.

Range("A1").Font.Bold = True
Range("A1").Font.Italic = True
Range("A1").Font.Underline = True

With these properties, you need to define TRUE or FALSE. So if the font is already bold or italic and you want to remove it, then you need to use FALSE to remove them.

Other Useful Font Properties

Here add a few more properties that can be useful for you (Strikethrough, Subscript, and Superscript).

Range("A1").Font.Strikethrough = True
Range("A1").Font.Subscript = True
Range("A1").Font.Superscript = True

More Tutorials

    • Count Rows using VBA in Excel
    • Excel VBA Hide and Unhide a Column or a Row
    • Excel VBA Range – Working with Range and Cells in VBA
    • Apply Borders on a Cell using VBA in Excel
    • Find Last Row, Column, and Cell using VBA in Excel
    • Insert a Row using VBA in Excel
    • Merge Cells in Excel using a VBA Code
    • Select a Range/Cell using VBA in Excel
    • SELECT ALL the Cells in a Worksheet using a VBA Code
    • ActiveCell in VBA in Excel
    • Special Cells Method in VBA in Excel
    • UsedRange Property in VBA in Excel
    • VBA AutoFit (Rows, Column, or the Entire Worksheet)
    • VBA ClearContents (from a Cell, Range, or Entire Worksheet)
    • VBA Copy Range to Another Sheet + Workbook
    • VBA Enter Value in a Cell (Set, Get and Change)
    • VBA Insert Column (Single and Multiple)
    • VBA Named Range | (Static + from Selection + Dynamic)
    • VBA Range Offset
    • VBA Sort Range | (Descending, Multiple Columns, Sort Orientation
    • VBA Wrap Text (Cell, Range, and Entire Worksheet)
    • VBA Check IF a Cell is Empty + Multiple Cells

    ⇠ Back to What is VBA in Excel

    Helpful Links – Developer Tab – Visual Basic Editor – Run a Macro – Personal Macro Workbook – Excel Macro Recorder – VBA Interview Questions – VBA Codes

    Цвет шрифта Excel VBA

    Свойство VBA Font Color можно использовать для изменения цвета шрифта ячеек Excel с помощью кода VBA. Используя индекс цвета и свойство цвета с функцией RGB, мы можем изменить цвет шрифта несколькими способами.

    Когда мы готовим информационную панель в excelПодготовка информационной панели в ExcelИнформационная панель в Excel — это расширенный инструмент визуализации, который предоставляет обзор важнейших показателей и точек данных для бизнеса. Преобразовывая необработанные данные в содержательную информацию, информационная панель упрощает процесс принятия решений и анализа данных. Подробнее, мы обычно тратим много времени на форматирование ячеек, шрифты и т. д. Часто мы чувствуем себя косметологами Excel, глядя на различные цвета. форматирования Excel. Например, изменение цвета шрифта на листе Excel — простая задача, но когда дело доходит до Excel, вы должны знать, как писать код VBA. Написание кода VBA Код VBA — это набор инструкций, написанных пользователем в программировании приложений Visual Basic. языка в редакторе Visual Basic (VBE) для выполнения определенной задачи. Подробнее об изменении цвета шрифта.

    Чтобы изменить цвет шрифта, во-первых, нам нужно определить, какие ячейки мы собираемся изменить.

    Диапазон («A1:A10»)

    Затем нам нужно выбрать свойство FONT.

    Диапазон («A1:A10»). Шрифт

    Тогда что мы хотим сделать с этим шрифтом? Итак, выберите цвет.

    Диапазон («A1:A10»). Шрифт. Цвет

    Таким образом, нам нужно создать код для изменения цвета шрифта. Это не выглядит легко.

    Но помните, вначале все кажется трудным. Позже вы освоитесь.

    Оглавление

    • Цвет шрифта Excel VBA
      • Как изменить цвет шрифта с помощью VBA?
        • Пример №1 – Использование цветового индекса
        • Пример №2 – Использование свойства цвета
        • Пример №3 – Использование свойства цвета с функцией RGB
      • Рекомендуемые статьи

    Цвет шрифта VBA

    Как изменить цвет шрифта с помощью VBA?

    .free_excel_div{фон:#d9d9d9;размер шрифта:16px;радиус границы:7px;позиция:относительная;margin:30px;padding:25px 25px 25px 45px}.free_excel_div:before{content:»»;фон:url(центр центр без повтора #207245;ширина:70px;высота:70px;позиция:абсолютная;верх:50%;margin-top:-35px;слева:-35px;граница:5px сплошная #fff;граница-радиус:50%} Вы можете скачать этот шаблон Excel цвета шрифта VBA здесь — Цвет шрифта VBA Шаблон Excel

    Пример №1 – Использование цветового индекса

    Свойство Color Index отличается от свойства Color в VBAColor Свойство В VBAVBA Color Index используется для изменения цветов ячеек или диапазонов ячеек. Эта функция имеет уникальную идентификацию для различных типов цветов.Подробнее. Используя числовые значения, мы можем изменить цвет ячеек и шрифтов.

    Числа варьируются от 1 до 56, и каждое число представляет разные цвета. Ниже приведен список чисел и их цветов.

    Пример цвета шрифта VBA 1

    Давайте проверим это.

    У нас есть значение в ячейке A1.

    Пример цвета шрифта VBA 1-1

    Мы хотим изменить цвет шрифта ячейки A1 на зеленый. Ниже приведен код.

    Код:

    Sub FontColor_Example1() Range («A1»). Font.ColorIndex = 10 End Sub

    Это изменит цвет шрифта ячейки A1 на зеленый.

    Пример VBA FontColor 1-2

    Мы также можем использовать свойство CELLS для изменения цвета шрифта.

    Код:

    Sub FontColor_Example1() Cells(1, 1).Font.ColorIndex = 10 End Sub

    Таким образом, мы можем использовать числа от 1 до 56, чтобы применить желаемый цвет к шрифту.

    Пример №2 – Использование свойства цвета

    Color Index имеет очень ограниченное количество цветов от 1 до 56, но с помощью свойства COLOR мы можем использовать 8 встроенных цветов: vbBlack, vbRed, vbGreen, vbBlue, vbYellow, vbMagenta, vbCyan, vbWhite.

    Для этих цветов нам не нужно указывать какие-либо числа. Скорее, мы можем получить к ним доступ, используя их имя, как показано выше. Ниже приведен пример кода для всех 8 цветов.

    Код:

    Sub vbBlack_Example() Range(«A1»).Font.Color = vbBlack End Sub

    Код:

    Sub vbRed_Example() Range(«A1»).Font.Color = vbRed End Sub

    Код:

    Sub vbGreen_Example() Range(«A1»).Font.Color = vbGreen End Sub

    Код:

    Sub vbBlue_Example() Range(«A1»).Font.Color = vbBlue End Sub

    Код:

    Sub vbYellow_Example() Range(«A1»).Font.Color = vbYellow End Sub

    Код:

    Sub vbMagenta_Example() Range(«A1»).Font.Color = vbMagenta End Sub

    Код:

    Sub vbCyan_Example() Range(«A1»).Font.Color = vbCyan End Sub

    Код:

    Sub vbWhite_Example() Range(«A1»).Font.Color = vbWhite End Подпример №3 — Использование свойства цвета с функцией RGB

    Мы видели, что у нас есть только 8 встроенных цветов для работы. Но нам нужно использовать функцию RGB, чтобы иметь разные цвета. Помимо встроенных цветов, мы можем создавать наши цвета с помощью VBA VBA RGBVBA RGBRGB также можно назвать красным, зеленым и синим, эта функция используется для получения числового значения значения цвета, эта функция имеет три компонента: диапазон, и они красный, синий и зеленый, другие цвета рассматриваются как компоненты этих трех разных цветов в функции VBA.

    Посмотрите на синтаксис функции RGB.

    RGB (красный, зеленый, синий)

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

    Ниже приведены несколько примеров для вас.

    Пример VBA FontColor 3

    Ниже приведены некоторые примеры кода макроса.

    Код:

    Sub RGB_Example() Range(«A1»).Font.Color = RGB(0, 0, 0) ‘Изменить цвет шрифта на черный End Sub

    Код:

    Sub RGB_Example() Range(«A1»).Font.Color = RGB(16, 185, 199) ‘Цвет шрифта будет этим End Sub

    Код:

    Sub RGB_Example() Range(«A1»).Font.Color = RGB(106, 15, 19) ‘Цвет шрифта будет этим End Sub

    Код:

    Sub RGB_Example() Range(«A1»).Font.Color = RGB(216, 55, 19) ‘Цвет шрифта будет этим End Sub

    Рекомендуемые статьи

    Эта статья была руководством по цвету шрифта VBA. Здесь мы узнаем, как изменить цвет шрифта, используя индекс цвета VBA, свойство цвета с функцией RGB вместе с примерами и загрузим шаблон Excel. Ниже приведены некоторые полезные статьи Excel, связанные с VBA:

    • Примеры VBA
    • ЧДир ВБА
    • Альтернативный цвет строки в Excel

    You have received an Excel file and somebody has highlighted text with a different font color? If you are talking about a few cells only – no problem. But what, if you file has hundreds of rows? How do you return the fore color from the text (or number) cells?

    Method 1: Do it manually with these tricks

    Unfortunately, Excel does not provide any built-in method to retrieve the font color of the cell. That – as usually – means that you have to use a VBA macro. But let’s take a step back. Do you really need the font color code retrieved by a function? Yes, there might be reasons, for example when you want to automate or frequently update the file. But if that’s not the case, why don’t we look for a workaround?

    Use the filter by color function

    Use the filter function to filter or sort by font color.
    Use the filter function to filter or sort by font color.

    The filter in Excel is very powerful. Besides normal filtering, it can also sort data or filter and sort by color. If the items in your list or table have different colors (also background colors), the “Filter by Color” option is not greyed-out.

    So, just filter here for your desired color and then you can add color labels (for example “red” in the column next to the filtered column).

    Use the Find function to select cells by font color

    Use the Find function to search and select by font color.
    Use the Find function to search and select by font color.

    If you want to search for specific colors, you can use the Excel Find window to search for a format.

    1. Open the Find and Replace window by pressing Ctrl + F on the keyboard.
    2. Click on “Format”.
    3. On the Font tab, select the color you want to search for.
    4. Confirm with OK.
    5. Click on “Find All”.
    6. Select all the search results. Excel then selects automatically the respective cells in your workbook.

    Method 2: Return the font color with a short VBA macro

    Return the index of the fore color

    If you just need the color index, you can use the following very simple VBA macro. Open the VBA editor (Alt + F11 on the keyboard), insert a new module and paste the following code. Please refer to this article for all the steps in detail.

    Function ProfessorExcelFontColor(cell As Range)
        ProfessorExcelFontColor = cell.Font.Color
    End Function
    
    Return the color index with a short VBA macro.

    Back in your worksheet, type the following function (replace B5 with your desire cell reference):

    =ProfessorExcelFontColor(B5)

    Return the RGB code for the font color

    Similar to the previous VBA macro (above), you can insert a slightly modified version. It returns the RGB code of the font color.

    Again, open the VBA editor window (press Alt + F11 on the keyboard), insert a new module and paste the following source code.

    Function ProfessorExcelFontRGB(cell As Range)
        Dim PROFEXColorIndex As Long
        Dim PROFEXColor As Variant
    
        PROFEXColorIndex = cell.Font.Color
        
        PROFEXColor = PROFEXColorIndex Mod 256
           
        PROFEXColor = PROFEXColor & ", "
        PROFEXColor = PROFEXColor & (PROFEXColorIndex  256) Mod 256
           
        PROFEXColor = PROFEXColor & ", "
        PROFEXColor = PROFEXColor & (PROFEXColorIndex  256  256) Mod 256
    
        ProfessorExcelFontRGB = PROFEXColor
    End Function
    Return the RGB value of the font color.
    Return the RGB value of the font color.

    In your Excel cell, use the following function. Again, please replace the B5 with your cell reference.

    =ProfessorExcelFontRGB(B5)

    Do you want to boost your productivity in Excel?

    Get the Professor Excel ribbon!

    Add more than 120 great features to Excel!


    Method 3: Comfortably return the text color with Professor Excel Tools

    This is probably the most convenient method: Use our Excel add-in “Professor Excel Tools”. Install the add-in and type

    =PROFEXFontColor(B16,FALSE)

    for the font index and

    =PROFEXFontColor(B16,TRUE)

    for the RGB value.

    Or, you need a little bit more guidance? Insert the PROFEX function with the function tool:

    Return the font color for free with Professor Excel Tools.

    Return the font color for free with Professor Excel Tools.
    1. Click on Function on the Professor Excel ribbon.
    2. Select the function to insert (here: PROFEXFontColor).
    3. As the cell reference, type or select the cell with the font color you want to return.
    4. Type TRUE for the RGB value or FALSE for the color index.
    5. Click on “Insert Function”.

    Easy, right? And the best: Although the free trial version expires after 7 days, this function you can continue to use. It’s free. The reason is that if you collaborate with someone else the =PROFEX() functions should work for all users – even if they don’t have the unlimited license.


    Professor Excel Tools Box

    This function is included in our Excel Add-In ‘Professor Excel Tools’

    (No sign-up, download starts directly)


    Image by Gábor Adonyi from Pixabay

    Понравилась статья? Поделить с друзьями:
  • What is financial modelling in excel
  • What is financial modeling in excel
  • What is filtering in excel
  • What is file tab in excel
  • What is file path in word