Changing the Outline Color of the Selected Cell

Written by Allen Wyatt (last updated November 12, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


On Jim's system, the selected cell within a worksheet is outlined in green. With his eyesight dimming, this is difficult for Jim to see. He wonders if it is possible to change the outline of the selected cell to red.

There is no way to set the outline color within Excel. The program, does, however, allow you to set the color of the on-screen grid that is used to delineate cells. So, one approach might be to change the grid color, which would allow the existing cell outline to "stand out" in contrast to the grid color. For instance, you might want to change the grid color to red. You can do that by following these steps:

  1. Display the Excel Options dialog box. (In Excel 2007 click the Office button and then click Excel Options. In Excel 2010 or a later version, display the File tab of the ribbon and then click Options.)
  2. Click Advanced at the left side of the dialog box.
  3. Scroll through the options until you see the Display Options for this Worksheet section. (See Figure 1.)
  4. Figure 1. The Advanced options of the Excel Options dialog box.

  5. Ensure the Show Gridlines check box is selected.
  6. Using the Gridline Color drop-down list, choose the color you want to use. (In this case, choose a red hue.)
  7. Click OK.

If that approach doesn't work for your needs, then you might try setting up a macro to automatically change the background color of whatever cell is selected. (This doesn't change the selection border—remember that cannot be changed in Excel.) Here's one macro that can be used:

Dim cPrev As Range
Dim nPrev As Long

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If cPrev Is Nothing Then
        Set cPrev = ActiveCell
        nPrev = xlNone
    End If

    cPrev.Interior.Color = nPrev                ' Reset previously active cell

    Set cPrev = ActiveCell                      ' Remember
    nPrev = ActiveCell.Interior.Color
    If nPrev = vbWhite Then nPrev = xlNone      ' Color vbWhite erases borders

    ActiveCell.Interior.Color = vbYellow        ' Set highlight
End Sub

This macro is an event handler, and it needs to be placed in the worksheet's code window. (Right-click the worksheet you want to affect, then choose View Code from the resulting Context menu.) The event handler run every time you select a different cell.

You can also look to the Windows accessibility options to modify how information is displayed onscreen, or you can try third-party software such as ZoomText:

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10343) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Printing a File List

It is often helpful to have a list of all the documents in a given directory or folder. Word doesn't have a built-in way ...

Discover More

Font Substitution Problems

When your document uses fonts that are not available on your computer system, Word substitutes other fonts that it feels ...

Discover More

Entered Values are Divided by 100

Enter a value into a cell and "poof!" it is automatically divided by 100. What's going on, and how can you fix it so that ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Losing Data in a Shared Workbook

When you create a shared workbook, you run the risk of losing some of the data in that workbook. Here's a discussion ...

Discover More

Inadvertantly Getting Rid of Frozen Panes

Excel provides quite a bit of flexibility in displaying your data. You can have multiple windows visible for the same ...

Discover More

Disabled Page Setup Tools

It can be frustrating if you expect to use some of Excel's tools normally available on the ribbon, but those tools are ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 1?

2022-11-17 15:41:27

J. Woolley

Steve J's initial comment inspired the following code to highlight the active cell and its row using conditional formatting. (see Figure 1 below)

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim S As String, C As Long, P As Integer, R As Range
    Dim FC As FormatCondition, B As Boolean
    ' this code applies fill to active cell
    C = &HCCF2FF ' pale gold color
    P = 1
    Set R = ActiveCell
    GoSub UpdateFC
    ' this code applies fill to active cell's row
    S = "=N(""FILL ACTIVE ROW"")+TRUE"
    C = &HDAEFE2 ' pale green color
    P = 2
    Set R = Rows(ActiveCell.Row)
    GoSub UpdateFC
    Exit Sub
    ' this code is a common subroutine
    For Each FC In Me.Cells.FormatConditions
        With FC
            B = (.Formula1 = S)
            If B Then
                .ModifyAppliesToRange R
                .Priority = P
                Exit For
            End If
        End With
    Next FC
    If Not B Then
        With R.FormatConditions.Add(xlExpression, , S)
            .Interior.Color = C
            .Priority = P
            .StopIfTrue = False
        End With
    End If
End Sub

1. The code has two parts. Part 1 fills the active cell with pale gold. Part 2 fills the active cell's row with pale green. (The colors are arbitrary.) Either part can be deleted; in this case, make P = 1 and delete the following 6 individual lines:
    GoSub UpdateFC
    GoSub UpdateFC
    Exit Sub
    ' this code is a common subroutine
2. The code uses Excel's N function to add text identifying the conditional formats.
3. The code must be placed in a Sheet module (like Sheet1). It will activate each time the selection is changed on that worksheet.
4. A worksheet with the code will lose the ability to Undo (Ctrl+Z) or Redo (Ctrl+Y) any action.
5. The code is best with a worksheet displaying a large number of used cells in Excel's window (reduced font size or Zoom factor, for example).
6. To apply the code to all worksheets in a workbook, remove it from all Sheet modules and add it to ThisWorkbook module as
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
then replace this line
    For Each FC In Me.Cells.FormatConditions
with this line
    For Each FC In Sh.Cells.FormatConditions
In this case, all worksheets in the workbook will lose Undo/Redo capability.
7. Conditional formats are dynamic (modified by user or code); therefore, they are reevaluated each time this code is activated.

Figure 1. 

2022-11-16 04:16:13

Steve J

@Peter I use this setup in sheets containing 40 columns & about 200 rows & it's pretty much instantaneous.
I only apply the conditional formatting to the used range & not the entire row (although applying to entire row only has a marginal effect on speed).
For disclosure my system is a modest Lenovo Thinkpad with i5 processor with 8GB ram so not excessive.

The UDF just enters the current row No in to "F1" (or where ever you want to put it. The second formula goes into the conditional formatting to compare the current row with "F1" which will produce a TRUE and thus trigger the conditional formatting to be applied.

2022-11-16 00:27:35


Steve J. I found that putting the UDF in condition formatting cause quite a lag and that the direct change of the region's colour was much quicker

2022-11-14 18:02:23


Thanks for a lot of interesting comments. I will be trying the suggestions out.

2022-11-13 08:23:38

Steve J

I have some worksheets that are quite wide & it's easy to lose track when reading across the sheet. I use the following to highlight the current row.

First some vba code placed in the sheet module.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

crow = ActiveCell.Row
Range("F1") = crow

End Sub

Secondly the following formula in conditional formatting


& pick a fill colour of your choice & set the "applies to" area to the the useable part of the worksheet.

I make the text colour of F1 very light grey so as not to detract from the sheet contents. Obviously F1 could be changed to any cell that suits.

As ever when using vba code you will lose the undo facility.

2022-11-12 09:35:47

J. Woolley

See Chip Pearson's RowLiner:

2022-11-12 05:50:44


To my opinion, the simplest way would be to use a very bright color for the overall grid - so that the selected Cell/Range will get emphasized.
(see attached Pic.)
(see Figure 1 below)

Figure 1. 

2022-11-12 05:49:53


I've been used to pre-ribbon XL where I'd highlight cells with e.g. blue borders and when selected this would turn bright red (Inverting the colour, perhaps). Has this definitely been lost in ribbon versions? - Like Jim I can't find any way to do it now.

2022-11-12 05:39:25


Spreadsheets I use prior to Excel (SuperCalc, PlanPerfect) used to highlight the background colour of the row and of the column of which the selected cell was the intersection. This made it very easy to look at values in a particular row in a large table, something which can be difficult and error-prone in Excel. Why the Excel developers have not made this useful feature a display option is beyond me. I have certainly suggested it.
I will look into using Allen's code - thank you, Allen - to see if I can make something similar; the problem is doing so without destroying existing background colour settings in the respective row and column.

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.