View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Modify sub to work on cells with formulas

The sheet sub below works with values (1,2) input into the range IM2:IM100,
but fails if IM2:IM100 contains formulas returning the values 1,2. How can
it be modified to work with formulas? Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer, fcolor As Integer
If Not Intersect(Target, Range("IM2:IM100")) Is Nothing Then
Select Case Target
Case 1
icolor = 6
fcolor = 6
Case 2
icolor = 12
fcolor = 12
End Select

With Target
.Interior.ColorIndex = icolor
.Font.ColorIndex = fcolor
End With
End If
End Sub