Selection highlight color

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

hi,

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

bye
Abhilash
 
Hi Abhilash,

news.microsoft.com said:
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]
 
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 said:
Hi Abhilash,

news.microsoft.com said:
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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top