View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Squeaky Squeaky is offline
external usenet poster
 
Posts: 155
Default Highlight selected cells only

I found this at http://www.cpearson.com/excel/excelM...ightActiveCell
As per instructions use the following code in the
Workbook_SheetSelectionChange event of the workbook.

It works great.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Static OldRange As Range
On Error Resume Next
Target.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target

End Sub

Squeaky

"Squeaky" wrote:

Hi RJJ,

The best I have been able to work out is you will have to select another
cell then reclick the first cell to change the color back to no color. I do
not know if it is possible to change to a color when you click on, and change
back when you click off a cell.

Squeaky

"RJJ" wrote:

Almost but,

the cell is changed to yellow but I need it to revert back to "no fill" when
unselected

"Squeaky" wrote:

Hi RJJ,

Since the macros take you to sected cells, you can add this to each macro.
If your selected cell on the first macro is A1:
(You can most likely omit the first line since your macro will take you to
the specified cell)

Range("A1").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With

This will add the color Yellow to the cell.

Squeaky

"RJJ" wrote:

I have a macro on sheet (1) that takes me to a specific cell on sheet (2). I
need the now selected cell on sheet(2) to highlight to some color (yellow
probably). The macros on sheet (1) are along side a long list of names. So as
I select the appropriate macro, the appropriate cell needs to highlight on
sheet (2). This workbook will ultimately be placed on a server drive so the
formatting, code, macro or whatever needs to be within the workbook and not
an add-on that is specific to the terminal.