View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default VBE Expert Help, Code linked to Cells

Just paste your code into sheet2 module

"JVANWORTH" wrote:

Mike,

Got it. Did it.

Question??? In Sheet 1 I have cell A4 "ENG 10P" in yellow. In Sheet 2 I
linked cell D10 to cell A4 in Sheet 1. The code in Sheet 2 will change the
cell to yellow the first time I enter "ENG 10" in A4, Sheet 1. But when I
change A4, Sheet 1, to "ENG 11", red, the color in D10, Sheet 2 stays yellow
but reads "Eng 11".
Is there anyway to insure the colors change in sheet two accordingly?

When I double click the cell D10, Sheet 2, and close it, the cell will
change to the correct color. Strange?

Thanks for your help,
John





"Mike" wrote:

or 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

"JVANWORTH" wrote:

Can Code be linked to cells?
Mike H graciously created this code to change cell colors per my question
which follows:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1:G10")) _
Is Nothing Then Exit Sub
Select Case Target.Value
Case "A" To "E"
icolor = 3
Case "F" To "J"
icolor = 41
Case "K" To "O"
icolor = 4
Case "P" To "T"
icolor = 6
Case Else
End Select
Target.Interior.ColorIndex = icolor
End Sub


"JVANWORTH" wrote:

I need a cell to change into four (4) different colors if a specific
condition is met. For example if A1 matches a text value €œA thru E€ I need
€œred€, if its a €œF thru J€ then €œblue€, €œK thru O€ then €œgreen€, €œP thru T€
then yellow.


I need to take this one step further. I have four list of high school
classes that I need to extend this to. I can type in each class (60 plus)
and assign a color in the code.
OR€¦..can I link the code to the list so it runs thru the list and matches
color. I my need to change/refresh the list once in a while.

Let me know if more info is needed.

Thanks
John