Changing Font Color Using RGB Values In VBA

tanny81

Board Regular
Joined
Mar 2, 2006
Messages
175
All,

I am currently using the below in a piece of code to change the colour of the text.

Code:
Cells(i, 11).Font.Color = RGB(107, 143, 0)

The problem I am having is that, although the colour is changed, the RGB values do not match those which I specify. For example, the above actually gets changed in the spreadsheet to 128, 128, 0.

I know this is a minor thing, but I can't understand why when specifying the colours like this, that they do not appear as expected. Any suggestions welcome.......

Thanks,
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
If you are using a version of Excel prior to 2007 you are limited to a colour palette of 56 colours. Excel will substitute the nearest match to your RGB value.
 
Upvote 0
You can, however, modify the color palette of your workbook (although you will be limited to a maximum of 56 if in Excel 2003 or below) via the workbook's colors property:

Code:
ActiveWorkbook.Colors(5) = RGB(107,143,0)
 
'then this will work:
 
Cells(i, 11).Font.Color = RGB(107, 143, 0)
 
Upvote 0

Forum statistics

Threads
1,225,280
Messages
6,184,033
Members
453,206
Latest member
Atko

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top