Functions Expert…..four (4) different colors if a specific conditi

J

JVANWORTH

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 it’s a “F thru J†then “blueâ€, “K thru O†then “greenâ€, “P thru Tâ€
then yellow.

I’m struggling with the set up of this requirement.
 
P

Peo Sjoblom

Which version are you using? In Excel 2007 you can do this but in previous
version you can only use 3 conditions, so if that's the case you need VBA
 
M

Mike H

try this:-

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) _
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
 
J

JVANWORTH

Mike H,

I'm sure this works, but my ability is limited in where to put. How do I
insert this into the work sheet. I need direction in order to execute.
 
J

JVANWORTH

What is VBA

Peo Sjoblom said:
Which version are you using? In Excel 2007 you can do this but in previous
version you can only use 3 conditions, so if that's the case you need VBA
 
T

T. Valko

Select the sheet where you want this to happen.
Right click on the sheet tab
Select View Code
This will open the VBE
Paste the code into the right side of the window that opens
ALT+Q to close the VBE and return to Excel

Biff
 
T

T. Valko

Here's a tip:

If you have an event macro like this that formats a cell *NEVER* select the
entire sheet and then click the "clear formats" button on your toolbar (if
you have that button on one of your toolbars). You will regret it!

Biff
 
J

JVANWORTH

Thanks.......I'll give it a go

T. Valko said:
Here's a tip:

If you have an event macro like this that formats a cell *NEVER* select the
entire sheet and then click the "clear formats" button on your toolbar (if
you have that button on one of your toolbars). You will regret it!

Biff
 
J

JVANWORTH

Thanks Again.......I got it to work.

What do I need to change if I want it to recongnize whole words or
phrases...ie...
Eng 9, Math 9, Science 9 would be red
Eng 10, Math 10, Science 10 would be blue

I have four lists of courses in a worksheet that need to be highlighted
their respective color when entered.

Can you help?

Thanks in Advance,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top