Note: The other languages of the website are Google-translated. Back to English

Excel: If the font color is red then return a specific text or do other operations

How could you return a specific text if the font color is red in another cell as below screenshot shown? In this article, I will introduce some tricks for doing some operations based on the red font text in Excel.


If font color is red then return specific text in another cell

To return a specific text if font color is red in another cell, please do as this:

1. Press Alt+ F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. Then, click Insert > Module, copy and paste the below VBA code into the window.

VBA code: If font color is red then return specific text

Function FontColorisRed(Rng As Range)
'Updateby ExtendOffice
    Application.Volatile
    If Rng.Font.ColorIndex = 3 Then
    FontColorisRed = "Fail"
    Else
    FontColorisRed = "Pass"
    End If
End Function
Note: In the above code, if the font color is red, then return the text “Fail”, if not red, return the text “Pass”. You can change the two texts, to your need.

3. Then, close the code window, and enter this formula: =FontColorISRed(B2), and then drag the fill handle down to get the other results, see screenshot:


If font color is red then highlight the cell

If you want to highlight the cells based on the red font, please do as this:

1. Press Alt+ F11 keys simultaneously to open the Microsoft Visual Basic for Applications window.

2. Then, click Insert > Module, copy and paste the below VBA code into the window.

VBA code: If font color is red then highlight the cell

Function HighlightRedFont(pRg As Range) As Boolean
'Updateby ExtendOffice
Dim xRg As Range
Dim xBol As Boolean
xBol = False
    For Each xRg In pRg
        If xRg.Font.Color = vbRed Then
            xBol = True
        End If
    Next
  HighlightRedFont = xBol
End Function

3. And then, close the code window, go to click Home > Conditional Formatting > New Rule, see screenshot:

4. In the popped out New Formatting Rule dialog box, do the following operations:

  • Click Use a formula to determine which cells to format in the Select a Rule Type list box;
  • Enter this formula =highlightredfont(B2) into the Format values where this formula is true text box;
  • Then, click Format button.

5. In the Format Cells dialog box, under the Fill tab, choose one color you want to highlight the cell, see screenshot:

6. And then, click OK > OK to close the dialog boxes. And now, the cells with red font are highlighted at once, see screenshot:


If font color is red then change the font color

Sometimes, you may want to change the red font to another font color, here I will talk about two methods for achieving it.

 If font color is red then change the font color with Find and Replace function

To change the red font color to another one, the Find and Replace feature in Excel can do you a favor, please do with the following steps:

1. Select the data range that you want to change the font color, and then press Ctrl + H keys to open the Find and Replace dialog box. In the opened dialog, click Options>> button, see screenshot:

2. In the expanded dialog box, do the following operations:

  • Leave the Find what and Replace with boxes blank;
  • On the right side of the Find what field, select Format > Choose Format From Cell, and click on a cell with red font;
  • Then, on the right side of the Replace with field, select Format > Format to go to the Replace Format dialog.

3. In the Replace Format dialog, under the Font tab, choose one color that you want to change from the Color drop down list, see screenshots:

4. Then, click OK to close the Replace Format dialog, and now, click Replace All button in the Find and Replace dialog box, all the cells with red font are replaced with the font color you specified, see screenshot:

Note: When you choose format from an existing cell, all formats of the cells will be picked up. In this case, when performing the Replace, if a format does not match exactly, the cell will not be replaced.

 If font color is red then change the font color with a useful feature

If you have Kutools for Excel, with its Select Cells with Format feature, you can select the cells with red font, and then change the font color to your need as quickly as possible.

After installing Kutools for Excel, please do as this:

1. Select the data range that you want to use, and then, click Kutools > Select > Select Cells with Format, see screenshot:

2. In the Select Cells with Format dialog box, click Choose Format From Cell button. And then, select a cell with red font, all attributes of this cell are displayed in the below list box. If you want to select all cells with the exactly same formatting of the base cell, please checked all attribute options; If you just want to select the cells with only red font, uncheck all other attributes except the Font Color checkbox. See screenshot:

3. Then, click OK button, and in the following prompt box, click Yes, see screenshot:

4. All cells with red font are selected at once, and then, you can specify a font color to change the red font as you need. See screenshot:



  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns and Keeping Data; Split Cells Content; Combine Duplicate Rows and Sum/Average... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Favorite and Quickly Insert Formulas, Ranges, Charts and Pictures; Encrypt Cells with password; Create Mailing List and send emails...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • Pivot Table Grouping by week number, day of week and more... Show Unlocked, Locked Cells by different colors; Highlight Cells That Have Formula/Name...
kte tab 201905
  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations