Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#183290 - 07/10/2003 08:27 Any MS Excel experts here? please help
puckalicious
member

Registered: 18/01/2002
Posts: 171
I have a spreadsheet that keeps track of various product ratings based on empirical test data. I have an IF statement that assigns a text rating based on a numerial value. For instance, if a result from Test A is less than 30%, then the next column shows the rating as "Good".

My question is related to cell formatting. Is it possible to have another IF formula (or macro) that assigns a cell brackground color based on the rating value. For instance, if the rating value is "Good", I want to be able to automatically have the cell background color set to green.

Has anyone done anything like this?

Top
#183291 - 07/10/2003 08:31 Re: Any MS Excel experts here? please help [Re: puckalicious]
furtive
old hand

Registered: 14/08/2001
Posts: 886
Loc: London, UK
I don't think you can colour cells using functions - I think you have to use VB script to do that.

It's been a while since I played with Excel in anger though...
_________________________
Mk2a RioCar 120Gb - now sold to the owner of my old car
Rio Karma - now on ebay...

Top
#183292 - 07/10/2003 08:47 Re: Any MS Excel experts here? please help [Re: puckalicious]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
You could use Conditional Formatting if you don't need to highlight that many different things.

Top
#183293 - 07/10/2003 08:53 Re: Any MS Excel experts here? please help [Re: puckalicious]
Mach
old hand

Registered: 15/07/2002
Posts: 828
Loc: Texas, USA
Here's something that we did for a manager recently.

Sub ChangeTheColor()
Dim CRed, CGreen, CYellow, CNone
CRed = 3
CYellow = 6
CGreen = 4
For Each cell In Selection
'if the cell is less than 33% then color it solid red
If cell.Value < 0.33 And cell.Value >= 0 Then
cell.Interior.ColorIndex = CRed
cell.Interior.Pattern = xlSolid
'if the cell is less than 66% then color it solid yellow
ElseIf cell.Value > 0.33 And cell.Value <= 0.66 Then
cell.Interior.ColorIndex = CYellow
cell.Interior.Pattern = xlSolid
'if the cell is more than 66% then color it solid green
ElseIf cell.Value > 0.66 And cell.Value <= 1 Then
cell.Interior.ColorIndex = CGreen
cell.Interior.Pattern = xlSolid
'anything else remove the color
Else
cell.Interior.ColorIndex = xlNone
End If
Next cell
End Sub


Sorry, it's a little tough to read. The bbs seems to eat the formatting.

Top
#183294 - 07/10/2003 09:11 Re: Any MS Excel experts here? please help [Re: puckalicious]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Yeah. Look up "conditional formatting" in the Excel help.
_________________________
-- roger

Top
#183295 - 07/10/2003 11:30 Re: Any MS Excel experts here? please help [Re: Roger]
puckalicious
member

Registered: 18/01/2002
Posts: 171
Conditional Formatting!
Brilliant!
I take that back. It will only apply 3 conditional formats, and of course I have 4 to apply.

Mach - this macro seems to work by cell increments, what if the cells I want to format are not in a well thought out order? Could the macro search for any cells with the text "Good" or "Poor" and automatically update them based on the text? What if the text was the result of a cell function?

Top
#183296 - 07/10/2003 11:33 Re: Any MS Excel experts here? please help [Re: puckalicious]
puckalicious
member

Registered: 18/01/2002
Posts: 171
Nevermind. I just found out if I set the default cell format to that of my 4th condition, it will remember it if/when the cell value changes.
Thanks for all the help!

Top