How To Highlight Selected Text In Excel (8 Ways)

Here’s an overview of where you can find the conditional highlight options in Excel.

Overview of Highlighting

Method 1 – Highlight Text in Excel Using the Font Color

  • Select the range of text you want to highlight.
  • Go to the Font group under the Home ribbon and click on Font Color.
  • Select any color from the Theme Colors group.

Highlight Using Font Color

  • The output will look to the following image.

Output of Highlighting by Font Color

Read More: How to Highlight Lowest Value in Excel

Method 2 – Using Excel Cell Styles to Highlight Text

  • Select the cells that you want to highlight.
  • Under the Home ribbon, select Cell Styles.
  • Choose any of the options.

Highlight Using Cell Styles

  • If you choose the option Check Cell, your output will look similar to the following image.

Applying Cell Styles to Highlight Text in Excel

Method 3 – Highlight Specific Text Using Format Cells

  • Select the dataset.
  • Press Ctrl + 1 to open the Format Cells dialog box.

Select Cells to Apply Format Cells Highlighting

  • Change the options in the dialog box accordingly.

Format Cells Dialog Box

  • Here’s a sample result.

Highlight Only Text by Using Format Cells Dialog Box

Read More: How to Highlight Highest Value in Excel

Method 4 – Using a Pop-up Menu to Highlight Text in Excel

  • Select the text in a certain cell. A pop-up menu would appear like the following image.
  • Click on the Font Color option and select any of the colors available to highlight the text.

Highlight by Pop-up Menu

  • Here’s a sample result.

Output of Highlighting by Pop-up Menu

Method 5 – Highlight Text with Conditional Formatting

  • Select the range and then select Conditional Formatting under the Styles ribbon group from the Home.
  • We chose “Text that Contains” as a condition.

Select Options to Apply Conditional Formatting

  • A dialog box appears. Provide the conditions based on which Excel will apply to format.

Applying Condition of Highlighting

  • Your output will look like the following image.

Output of Applying Conditional Formatting

Method 6 – Highlight Text Using Excel Formula

  • Select the text where you will apply highlighting.
  • Go to Conditional Formatting and select New Rule.

How to Highlight Using Formula

  • Apply a formula in the box Format values where this formula is true:
=$B5>150000

Applying Formula for Formatting

  • When you click on the Format… button, a dialog box will appear prompting you to choose a color for formatting.

Choosing Color for Formatting

  • Here’s a sample result.

Output of Highlighting by Formula

Read More: How to Highlight Text in Text Box in Excel

Method 7 – Applying Excel VBA Code to Highlight Text

  • Press Alt + F11 to open the VBA Editor.
  • Under the Insert tab, click on Module.

Creating New Module in VBA Editor

  • Copy the following VBA code.
Sub Highlight_Multiple() Dim Input1 As Variant Dim rng As Range ' Prompt the user for input Input1 = Split(InputBox("Enter the words(separated by comma):"), ",") ' Set the range where you want to search for the text Set rng = Range("B5:D11") ' Modify the range as per your dataset ' Clear any previous highlighting rng.Interior.Pattern = xlNone ' Search for the words and highlight the matching cells For Each word In Input1     For Each cell In rng         If InStr(1, cell.Value, Trim(word), vbTextCompare) > 0 Then             'Change the highlighting color as needed             cell.Interior.Color = RGB(255, 0, 0)         End If     Next cell Next word End Sub
  • Paste the code in the editor and save it.

Code to Highlight Text in Excel

  • Go back to the Excel workbook and select the whole data table.
  • Press Alt + F8 to open the Macro window.
  • Select the Highlight_Text code and hit Run.

Running the VBA Code

  • An input box will appear. Insert the text you want to highlight. We put “Pencil” in the box since we want to highlight it in the data table.

Giving Input to Highlight Text

  • Your output will look like the following image.

Highlight Text by Applying VBA Code in Excel

How Does the Code Function?

Inp = InputBox(“Enter text to highlight:”)

Prompts the user to provide the text that the code will highlight. Assign the user’s input to a variable named “Inp”.

Set rng = Range(“B2:D11”)

Declares the variable “rng” to hold the range from B2 to D11 since our data is in this range.

For Each cell In rng

Loops through all the cells in the range “rng” and checks whether it meets certain criteria.

If InStr(1, cell.Value, Inp, vbTextCompare) > 0 Then

The VBA InStr function starts the comparison of text from the beginning of each “cell” in the “rng” variable. If it finds a match, then it will return a value greater than zero (the position of the starting substring in the first string). In that case, the condition becomes true, and the code is on the next line under the condition.

How to Create a Highlight Style in Excel

  • Select the Home tab and go to Cell Styles.
  • Under the Cell Styles group, click on New Styles.

How to Create New Cell Style

  • In the Style box, name your cell style and click on the Format… button.

Giving Name to the Style

  • In the Format Cells dialog box, under the Font tab, modify the Font as needed.

Modifying the Font in New Cell Styles

  • We will also change the default Fill.

Change Default Fill of the Style

  • Click OK twice to create the new style.
  • Select the whole dataset except the heading and click on Cell Styles and choose My Style.

Highlight Text with New Style in Excel

Highlight More Than One Text

  • Open the VBA Editor.
  • Copy the following code.
Sub Highlight_Multiple() Dim Input1 As Variant Dim rng As Range ' Prompt the user for input Input1 = Split(InputBox("Enter the words(separated by comma):"), ",") Set rng = Range("B5:D11") ' Modify the range as per your dataset ' Search for the words and highlight the matching cells For Each word In Input1     For Each cell In rng         If InStr(1, cell.Value, Trim(word), vbTextCompare) > 0 Then             'Change the highlighting color as needed             cell.Interior.Color = RGB(120, 120,160)         End If     Next cell Next word End Sub
  • Paste the code into the editor and save it.

VBA Code to Highlight Multiple Text

  • Go back to the Excel workbook and select the whole data table.
  • Press Alt + F8 together to open the Macro window.
  • Select the Highlight_Multiple code and hit Run.

Running the Code to Highlight Multiple Text in Excel

  • An input box will appear where you will write down the texts you want to highlight. We put “Pencil,3,2” in the box since we want to highlight it in the data table. Separate each string with a comma (without spaces).

Giving Input to Highlight

  • Excel has colored all the cells in the dataset that contain at least one of the chosen strings.

Highlight More Than One Text in Excel

How Does the Code Function?

The above code is very similar to the code we used in the earlier session. We have modified that code just in 2 places.

  1. We introduced an extra For loop in order to loop all the words that the user gives.
  2. Instead of using the direct input, we first used the VBA Trim function to extract the words free of other delimiters like commas.

How to Highlight Duplicate Text in Excel

  • Select the range where you want to check for duplicates.
  • Under Conditional Formatting, select Highlight Cells Rules and choose Duplicate Values.

Highlighting Duplicate Values

  • A user prompt box will appear, giving you the option to choose the format you want to apply.
  • Choose a format and click OK.

Option Box to Choose Type of Highlighting

  • The duplicate values in your dataset are highlighted now.

Highlight Duplicate Text in Excel

Frequently Asked Questions

Does highlighting cells affect the calculation or function results in Excel?

Highlighting is just a visual formatting feature that does not impact the data or formulas.

Are there any limitations to highlighting cells in Excel?

Yes, excessive highlighting in your worksheet can impact performance. Also, the highlighting you apply to cells may not appear as expected when printing a worksheet. So, it is a good idea to preview and adjust print settings before printing to ensure accuracy.

Can I highlight cells in Excel using a formula?

Yes, you can highlight cells in Excel using a formula by applying conditional formatting.

Download the Practice Workbook

Highlighting Text.xlsm

Related Articles

  • How to Highlight a Column in Excel
  • How to Compare Two Excel Sheets and Highlight Differences

<< Go Back to Highlight in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!

Tag » How To Highlight In Excel