change row colour when cell is selected for ease


Well-known Member

I have a sheet but in struggling to see if I'm on the correct row when im filling it in
Can you change the row colour when a cell is selected?

ie: if I select any thing between G21:AE21 I can get A21:E21 to change colour
But if nothing is selected then don't change anything

Hope ive explained it easy enough



Board Regular
Here are the steps to highlight the active row.

Select the data you want to highlight.

Go to the Home tab.
Click on Conditional Formatting and then click on New Rule.
In the New Formatting Rule dialog box, select “Use a formula to determine which cells to format”.
In the Rule Description field, enter the formula: =CELL(“row”)=ROW())
Click on the Format button and specify the formatting (the colour in which you want the row highlighted).
Click OK.
The above steps have taken care of highlighting the active row whenever there is a selection change event.

However, to make this work, you need to place a simple VBA code in the backend.

Here is the VBA code that you can copy and paste.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Application.CutCopyMode = False Then
End If
End Sub
Last edited:

Some videos you may like

This Week's Hot Topics

  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • find many based on a certain criteria
    good evening, I hope someone can help me? I have a workbook sheet 2 contains lots of data.... I would like to be able to find anything on sheet...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
  • Text Format
    I have a sheet for user to keyin the data. The format of the data can be 451 / 1903, 0012 / 9908 or 00287 / 0099. The number after the "/" is...
  • Syntax errors
    Good Morning, Trying to compile a workbook, I keep getting a few errors. Here are the first two: [code=rich]Syntax Error: Function...