View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Change Interior Cell Color

Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ken Hudson" wrote in message
...
Perfect!
Thanks Don.
--
Ken Hudson


"Don Guillett" wrote:

Try this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 35
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Ken Hudson" wrote in message
...
I have a worksheet whose cells have different interior colors. When I
select
a cell, I want to change the interior color to 35. When I move on to
another
cell, I want to change that color back to its original color.
I found the following code to make the intial change, but haven't
figured
out how to return the original color.
Thanks for helping.

---------------------------------

Option Explicit
Dim OldActiveCell As Range

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Excel.Range)
If OldActiveCell Is Nothing Then
Set OldActiveCell = Target
Else
OldActiveCell.Interior.ColorIndex = xlNone
End If
Target.Interior.ColorIndex = 35
Set OldActiveCell = Target
End Sub
--
Ken Hudson