VBA code to change font color from red to black

gubertu

Board Regular
Joined
May 24, 2015
Messages
148
Hi all,

I´m looking for a code that changes in all the workbook, all the text that is in red colored (red font), into black (black font).

Would it be possible?

Thanks in advance!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
1 most important question: red color is hard coded or results of CF?
if hardcoded no problem: loop through all sheet, cells on each, check color and change.
 
Upvote 0
Do you have any cells with a font colour other than red, or black that needs to remain as-is?
 
Upvote 0
Hello,

Yes, I have fonts in white, red, black and another colours.

It would be perfect to have a code that finds every text in red in the workbook and change the color into black.

Thanks!
 
Upvote 0
Hello,

Yes, I have fonts in white, red, black and another colours.

It would be perfect to have a code that finds every text in red in the workbook and change the color into black.

Thanks!


This one is going to be tricky. You are going to have to do something for me if you want this to work.

Run this code against your sheet. You will see I have Range("A1")...Please edit that to a Range that is currently the shade of red you are using.




Code:
Sub Get_Color_Code()
    Range("A1").Select
    MsgBox Selection.Font.Color
End Sub

Please post the color code. I suspect it will likely be 255.
 
Last edited:
Upvote 0
Ok, how about
Code:
Sub gubertu()
   Dim Ws As Worksheet
   
   With Application
      .FindFormat.Clear
      .FindFormat.Font.Color = 255
      .ReplaceFormat.Clear
      .ReplaceFormat.Font.ColorIndex = xlAutomatic
   End With
   
   For Each Ws In Worksheets
      Ws.UsedRange.Replace "", "", xlPart, , , , True, True
   Next Ws
End Sub
 
Upvote 0
Hello, this is working almost perfect! But... what if in the same text there are part text in black font and part text in red font? In this case, it is not changed to black.

Thanks again!

Example: ASSETS in (-)
 
Last edited:
Upvote 0
No, it won't be. The only way I know to do that would be to loop through every single used cell in each sheet, which could take a long time.

One thing, I forgot to reset the format's in the last code, it should be
Code:
Sub gubertu()
   Dim Ws As Worksheet
   
   With Application
      .FindFormat.Clear
      .FindFormat.Font.Color = 255
      .ReplaceFormat.Clear
      .ReplaceFormat.Font.ColorIndex = xlAutomatic
   End With
   
   For Each Ws In Worksheets
      Ws.UsedRange.Replace "", "", xlPart, , , , True, True
   Next Ws
   With Application
      .FindFormat.Clear
      .ReplaceFormat.Clear
   End With
End Sub
 
Upvote 0
Thanks for the last code.

I have an idea. What if we replace in all the workbook the text "in (-)" that is in red for the text "in (-)" in black¿?

This will solve my problem.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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