ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   change the fore color (https://www.excelbanter.com/excel-programming/384792-change-fore-color.html)

jimmy[_5_]

change the fore color
 
Which function is for changing the font color? and what is the color index?

Thanks



joel

change the fore color
 
There are no excel function for changing fonts or colors except the
conditional formating. In VBA youhavve to select a cell or range and then
change the Interior.colorindex or font.colorindex. Below is a macro that I
gort using the Learn Macro to get an example of these statements.

With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Selection.Font.ColorIndex = 3


"jimmy" wrote:

Which function is for changing the font color? and what is the color index?

Thanks




matt

change the fore color
 
On Mar 7, 9:12 pm, "jimmy" wrote:
Which function is for changing the font color? and what is the color index?

Thanks


Jimmy,

The color of font or the color of a cell is a property (i.e. an
adjective) of the range object (i.e. a subject). In order to change
the font color you must first specific a range object and then apply
the font property and then apply the color index property followed by
a color index number.

All colors are made up of RBG, but unless you know the right
combination of Red Blue and Green to make the colors that you want, it
might be easier to use color index (which is predefined by Excel to
include the palette in Menu Bar: Format/Cells/Patterns).

Fromatting syntax is often best learned by using the macro recording.
In short, you can search VBA help for colorindex to learn more.
Otherwise, the following should help.

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

(Range Object is Range("A1"), .Font is a property describing
"A1", .ColorIndex is also a property describing the font in "A1")

Hopefully this helps.

Matt



All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com