How to highlight Active Cell in Excel using Conditional Formatting.

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
Hey Excel Gurus,

I would like to know the formula for highlighting the active cell of my worksheet using Excel's built in Conditional Formatting rules.

Will appreciate and thank you.
 
Last edited:
Put the following code in the events of your sheet.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Calculate
End Sub

In the conditional format, put the following formula:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]=ADDRESS(ROW(),COLUMN())=CELL("address")[/TD]
[/TR]
</tbody>[/TABLE]

This way you can use the Undo command (Ctrl-z)

Try my file

https://www.dropbox.com/s/qsv1racfue6gucl/highlight Active Cell.xlsm?dl=0
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
@DanteAmor

Do you need the event procedure for the formatting to work?
In excel 2013 I don't.

@omairhe

You specifically say that you want to use conditional formatting.
This means that it will only highlight the cell if the cell is not empty.
 
Last edited:
Upvote 0
@DanteAmor

Do you need the event procedure for the formatting to work?
In excel 2013 I don't.

@omairhe

You specifically say that you want to use conditional formatting.
This means that it will only highlight the cell if the cell is not empty.

The Calculate event is not for the format, it is only for updating the sheet.
If the calculate event does not light up immediately, it could be updated by pressing F9.
The cell can be empty or with data or filled with color, even if the cell has another format conditions, it does not matter, the conditional format applies and the cell is illuminated, I recommend you take a look at my file.
 
Upvote 0
I recommend you take a look at my file.

Sorry, I only download xlsx files and so I cannot test.

What I did is to use the conditional formatting formula that you posted in a range and it behaved as I expected.
It works OK with cells that are not empty.
It works the same with and without the event procedure.
As I said I'm using excel 2013.
Hope it works OK for omairhe.
 
Last edited:
Upvote 0
Sorry, I only download xlsx files and so I cannot test.

What I did is to use the conditional formatting formula that you posted in a range and it behaved as I expected.
It works OK with cells that are not empty.
It works the same with and without the event procedure.
As I said I'm using excel 2013.
Hope it works OK for omairhe.


The formula works with any cell, empty or non-empty.
I have 2007 and I need the event procedure.

That is the idea, that works for omairhe.

@omairhe
Only one detail was missing. In the conditional format, in Refers to: Select all cells (=$1:$1048576)
 
Upvote 0
The formula works with any cell, empty or non-empty.
I have 2007 and I need the event procedure.

That is the idea, that works for omairhe.

@omairhe
Only one detail was missing. In the conditional format, in Refers to: Select all cells (=$1:$1048576)


I can confirm that formula works with any cell and my requirment is 100% fulfilled. Although the uploaded sheet did not work with my Excel 2019 version but following the steps provided by Dante Amor worked as a charm. Also event procedure is needed, without that it will not highlight the selected cell.

Thank you .
 
Last edited:
Upvote 0
I can confirm that formula works with any cell and my requirment is 100% fulfilled. Although the uploaded sheet did not work with my Excel 2019 version but following the steps provided by Dante Amor worked as a charm. Also event procedure is needed, without that it will not highlight the selected cell.

Thank you .

I'm glad to help you. I appreciate your kind comments.
 
Upvote 0
Hey, Dante. I stumbled across this post while looking for something entirely different. Love it. Very useful in excel 2016, because it can be hard to see the selected cell when I am focused on a different window. Thanks!
 
Upvote 0
Oh, one problem though. selecting the new cell and forcing a Calculate will cancel cut/copy mode. On the bright side i can still use it by taking out the VBA portion and keeping the Conditional formatting portion. Now to keep a cell highlighted for leter reference, i just press F9, and i can see it easily.
 
Upvote 0
Oh, one problem though. selecting the new cell and forcing a Calculate will cancel cut/copy mode.

Change this:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Calculate
End Sub


By this
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,767
Messages
6,180,848
Members
453,001
Latest member
coulombevin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top