VBE Help, when linked value change, color will not
John,
Worksheet events are triggered by data entry: hence when you
change A1, the target cell is A1 and you get the change.
To change linked cells, code needs to be added which will loop through the
whole range and changes any cells "linked" to the target cell.
"JVANWORTH" wrote:
I have received tremendous help for the following code from Mike ( Im
waiting for his reply, but Im in a crunch for time so I thought I would fly
this)
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1:G10")) _
Is Nothing Then Exit Sub
Select Case UCase(Target.Value)
Case "ENG 9"
icolor = 3
Case "ENG 10"
icolor = 4
Case "ENG 11"
icolor = 5
Case "ENG 12"
icolor = 6
Case "MATH 9"
icolor = 3
Case "MATH 10"
icolor = 4
Case "MATH 11"
icolor = 5
Case "MATH 12"
icolor = 6
Case "SCI 9"
icolor = 3
Case "SCI 10"
icolor = 4
Case "SCI 11"
icolor = 5
Case "SCI 12"
icolor = 6
Case Else
End Select
Target.Interior.ColorIndex = icolor
End Sub
This code will match any of the Cases listed above for cells A1:G10, then
the code throws in the designated color for the background.
If I type ENG 9 into A1, the cells background will change to red. (which
it should do)
If I link A10 to A1 (same sheet) the code executes perfectly the first
time. When I enter ENG 10 into A1, A1 background becomes green (which it
should), but A10 stays red with the new text, ENG 10 in the cell.
I need to get the links to change colors automatically. I can double click
the cell with the link and <enter and the correct color will post up.
Is there a refresh that needs to be done?
Thanks,
John
|