VBE Expert Help, Code linked to Cells
Try this and modify to your needs
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 = 3
Case "ENG 11"
icolor = 3
Case "ENG 12"
icolor = 3
Case "MATH 9"
icolor = 4
Case "MATH 10"
icolor = 4
Case "MATH 11"
icolor = 4
Case "MATH 12"
icolor = 4
Case "SCI 9"
icolor = 5
Case "SCI 10"
icolor = 5
Case "SCI 11"
icolor = 5
Case "SCI 12"
icolor = 5
Case Else
End Select
Target.Interior.ColorIndex = icolor
End Sub
"JVANWORTH" wrote:
Mike,
Sorry for the confusion. Compared to you I am a zero when it comes to Excel.
I got your Code to work as I said. I thought I could translate your work
with the "A to E" example to a larger scale.
What I have created for my high school is a Master Schedule for all
subjects. As specific subject are entered I need them to be color coded to
help balance classes per period...ie...all periods need a good balance of
9th, 10th, 11th, & 12th grade classes. I need each level of class colored to
help me visually balance the classes.
Here are four abbreviated list of classes in the work sheet:
A B C D
1
.
.
.
25 ENG 9 ENG 10 ENG 11 ENG12
26 MATH 9 MATH 10 MATH 11 MATH 12
27 SCI 9 SCI 10 SCI 11 SCI 12
If MATH 11 is selected from a drop down menu, A1, (already created) I need
it to be highlighted with, lets say, yellow€¦..so I need to expand your code
so it will recognize a course description from one of the four lists and
highlights it with a designated color.
Can the code be changed to seek out the lists instead of "A" to "E" example
which I gave you.....
The current spread sheet basically has colums periods and rows with teachers
assignment (ie€¦MATH 11)
Did that help?
"Mike H" wrote:
Hi,
I'm sure a lot of people can modify this but I'm afraid I don't understand
the question about what your further requirements are.
Mike
"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
|