Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Francisca Perez   on Jan 07 In MS Office Category.

  
Question Answered By: Hababah Younis   on Jan 07

This will do it:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim WatchRange As Range
Dim CellVal As Integer
For Each targ In Target.Cells

If targ = "" Or Not IsNumeric(targ) Then Exit Sub
CellVal = targ
Set WatchRange = Range("A1:c52")

If Not Intersect(targ, WatchRange) Is Nothing Then
Select Case CellVal
Case 0
targ.Interior.ColorIndex = 5
Case 1
targ.Interior.ColorIndex = 10
Case 2
targ.Interior.ColorIndex = 6
Case 3
targ.Interior.ColorIndex = 46
Case 4
targ.Interior.ColorIndex = 45
Case 5
targ.Interior.ColorIndex = 5
Case 6
targ.Interior.ColorIndex = 10
Case 7
targ.Interior.ColorIndex = 6
Case 8
targ.Interior.ColorIndex = 46
Case 9
targ.Interior.ColorIndex = 45
End Select
End If
Next targ
End Sub

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on This code does not work if i copy & paste above one cell Or get search suggestion and latest updates.


Tagged: