ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   color of active cell (https://www.excelbanter.com/excel-programming/327587-color-active-cell.html)

Robb27

color of active cell
 
I have a variant of an earlier post.
I want to change the color of the active cell to yellow, but when the active
cell changes to another cell, I want the cell to revert back to the original
color it was prior to becoming the active cell. - (hope that makes sense!)
Many thanks in advance for making my life easier.

keepITcool

color of active cell
 

Robb

I'm not a fan of such (useless) code, but.. If you think it serves a
purpose then put following in the sheet's code module

Option Explicit

Dim rngPrev As Range
Dim idxPrev As Long


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
Application.ScreenUpdating = False
If Not rngPrev Is Nothing Then rngPrev.Interior.ColorIndex = idxPrev
Set rngPrev = Target
idxPrev = rngPrev.Interior.ColorIndex
rngPrev.Interior.ColorIndex = 6
Application.ScreenUpdating = True
End Sub




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Robb27 wrote :

I have a variant of an earlier post.
I want to change the color of the active cell to yellow, but when the
active cell changes to another cell, I want the cell to revert back
to the original color it was prior to becoming the active cell. -
(hope that makes sense!) Many thanks in advance for making my life
easier.


Robb27

color of active cell
 
Thanks keepITcool. It is just what I needed to help my very non-computer
literate employes very much.

Robb

"keepITcool" wrote:


Robb

I'm not a fan of such (useless) code, but.. If you think it serves a
purpose then put following in the sheet's code module

Option Explicit

Dim rngPrev As Range
Dim idxPrev As Long


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
Application.ScreenUpdating = False
If Not rngPrev Is Nothing Then rngPrev.Interior.ColorIndex = idxPrev
Set rngPrev = Target
idxPrev = rngPrev.Interior.ColorIndex
rngPrev.Interior.ColorIndex = 6
Application.ScreenUpdating = True
End Sub




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Robb27 wrote :

I have a variant of an earlier post.
I want to change the color of the active cell to yellow, but when the
active cell changes to another cell, I want the cell to revert back
to the original color it was prior to becoming the active cell. -
(hope that makes sense!) Many thanks in advance for making my life
easier.



Tushar Mehta

color of active cell
 
You do know that XL highlights the selected cell by putting a border
around it *and* changing the color of the associated row & column
numbers.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , Robb27
@discussions.microsoft.com says...
I have a variant of an earlier post.
I want to change the color of the active cell to yellow, but when the active
cell changes to another cell, I want the cell to revert back to the original
color it was prior to becoming the active cell. - (hope that makes sense!)
Many thanks in advance for making my life easier.



All times are GMT +1. The time now is 12:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com