Change font color automatically

bassls

Board Regular
Joined
Jun 4, 2003
Messages
63
I have inherited a huge ss that has different rows layered using different fonts, italics and bold. For example, a level 1 item is bold/no italic, level 2 is bold/italic, level 3 is regular/no ital, and level 4 is regular/italic. I want to change these levels to different colors so they are easier to see (old eyes ;-)). The font style does not need to change, only the color. For example, would leave level 1 black but make level 2 red, level 3 blue, etc. Something like : IF font = bold, italic THEN font = red.

B
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I have inherited a huge ss that has different rows layered using different fonts, italics and bold. For example, a level 1 item is bold/no italic, level 2 is bold/italic, level 3 is regular/no ital, and level 4 is regular/italic. I want to change these levels to different colors so they are easier to see (old eyes ;-)). The font style does not need to change, only the color. For example, would leave level 1 black but make level 2 red, level 3 blue, etc. Something like : IF font = bold, italic THEN font = red.

B

like this

Code:
Sub loopy()
Do
ActiveCell.Offset(1, 0).Select
If ActiveCell.Font.Italic = True Then
    Selection.Interior.ColorIndex = 4
End If
If ActiveCell.Font.Bold = True Then
    Selection.Interior.ColorIndex = 3
End If
Loop Until IsEmpty(ActiveCell.Offset(1, 0)) = True
 
End Sub

obviously you will have to build on it as I havent got time to write the proper code, but this is basically what you want to do.
 
Upvote 0
Has this got Conditional Formatting applied?

If using 2003 then look at Format Menu > Conditional Formatting.

If using 2007 or higher then Home Tab > Conditional Formatting > Rules
 
Upvote 0
so if the cell is bold and italic the code would be;

If ActiveCell.Font.Bold.Italic = True Then
Selection.Interior.ColorIndex = 4


I am wanting to change the font color, not the cell color.
 
Upvote 0
so if the cell is bold and italic the code would be;

If ActiveCell.Font.Bold.Italic = True Then
Selection.Interior.ColorIndex = 4


I am wanting to change the font color, not the cell color.


No it would be like

if activecell.font.italic = true and activecell.font.bold = true then
selection.font.colorindex = 4
endif


4 is just a dummy by the way, I dont know what the color reference is for the colour you want but just record yourself changing the colour in a cell to find out :)
 
Upvote 0
Thank you so much. The folks on this site are always the best. The code works fine, i made a tweak to change the font color instead of the cell color.

Sub loopy()
Do
ActiveCell.Offset(1, 0).Select
If ActiveCell.Font.Italic = True Then
Selection.Font.ColorIndex = 4
End If
If ActiveCell.Font.Bold = True Then
Selection.Font.ColorIndex = 3
End If
If ActiveCell.Font.Italic = True And ActiveCell.Font.Bold = True Then
Selection.Font.ColorIndex = 5

End If
Loop Until IsEmpty(ActiveCell.Offset(1, 0)) = True

End Sub

Thanks again, B.
 
Upvote 0

Forum statistics

Threads
1,224,531
Messages
6,179,379
Members
452,907
Latest member
Roland Deschain

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