Forum Discussion

mikesail's avatar
mikesail
Copper Contributor
Jul 04, 2025

Using Excel fine I want to highlight the text in a cell

Hello,

 

I often use Excel Find to look for text. 

What I would like to do is have Excel highlight the text in the cell after the text is found. 

Currently Excel will just go to the cell.

Is this possible?

Thank You,

 

Michael

1 Reply

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Excel does not natively support highlighting only part of the text in a cell (like a highlighter in Word), especially not as part of the "Find" feature.

    However, with a small VBA macro, you can automatically highlight (color) the matched text within a cell after a search.

    Sub FindAndHighlightText()
        Dim ws As Worksheet
        Dim searchText As String
        Dim cell As Range
        Dim startPos As Long
    
        Set ws = ActiveSheet
        searchText = InputBox("Enter the text to find and highlight:")
    
        If searchText = "" Then Exit Sub
    
        For Each cell In ws.UsedRange
            If InStr(1, cell.Value, searchText, vbTextCompare) > 0 Then
                startPos = InStr(1, cell.Value, searchText, vbTextCompare)
                cell.Characters(startPos, Len(searchText)).Font.Color = RGB(255, 0, 0)
                cell.Characters(startPos, Len(searchText)).Font.Bold = True
            End If
        Next cell
    
        MsgBox "Highlighting complete!"
    End Sub

    It only works on plain text in cells (not formulas).

    It highlights the first occurrence in each cell.

     

    My answer is without guarantee

    Maybe this will help you a little

Resources