ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selection highlight color (https://www.excelbanter.com/excel-programming/335181-selection-highlight-color.html)

news.microsoft.com[_8_]

Selection highlight color
 
hi,

When cells are selected a blue color transparent color appears in the
selection. Is it possible to change the color programatically?

bye
Abhilash



Jake Marx[_3_]

Selection highlight color
 
Hi Abhilash,

news.microsoft.com wrote:
When cells are selected a blue color transparent color appears in the
selection. Is it possible to change the color programatically?


You could do this by placing code similar to the following in the
ThisWorkbook module:

Private rngOld As Range

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
If Not rngOld Is Nothing Then rngOld.Interior.ColorIndex = 0
Set rngOld = Selection
rngOld.Interior.Color = RGB(255, 0, 0)
ActiveCell.Interior.ColorIndex = 0
End Sub

As written, this will "overwrite" any fill colors your cells had prior to
being selected. You could use a static array to track the colors, then set
them back to the originals instead of setting colorindex=0 if you want.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


news.microsoft.com[_8_]

Selection highlight color
 
Hello,

Well i dont want to change the fill colours of the cell. Thanks for your
response... Any other approach available?

Regards,
Abhilash

"Jake Marx" wrote in message
...
Hi Abhilash,

news.microsoft.com wrote:
When cells are selected a blue color transparent color appears in the
selection. Is it possible to change the color programatically?


You could do this by placing code similar to the following in the
ThisWorkbook module:

Private rngOld As Range

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
If Not rngOld Is Nothing Then rngOld.Interior.ColorIndex = 0
Set rngOld = Selection
rngOld.Interior.Color = RGB(255, 0, 0)
ActiveCell.Interior.ColorIndex = 0
End Sub

As written, this will "overwrite" any fill colors your cells had prior to
being selected. You could use a static array to track the colors, then
set them back to the originals instead of setting colorindex=0 if you
want.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]





All times are GMT +1. The time now is 11:33 PM.

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