Active Cell Selector

kevin21

New Member
Joined
Nov 8, 2010
Messages
8
I found some code on an old Excel site on how to highlight the active cell. When this is running it does not allow you to copy and paste because you are updating the cell when you go to it. Is there a way to know if data is in memory for pasting so I can disable the code or is there a better way to highlight the active cell. I am posting the code below. Thanks

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)

Static OldRange As Range
Static OldColor As Integer
Static NewColor As Integer
On Error Resume Next
NewColor = Target.Interior.ColorIndex
Target.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.Interior.ColorIndex = OldColor
Set OldRange = Target
OldColor = NewColor
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
There is a better way. Select the entire range in the sheet, apply the following Conditional Formatting formula

=AND(ROW()=CELL("row"),COLUMN()=CELL("col"))

and select a suitable fill colour.


Right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks, but it seems my screen flashes several times before the color changes. Is there something else I need to look at?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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